Skip to content

Commit

Permalink
Improve backup log command UT coverage.
Browse files Browse the repository at this point in the history
Signed-off-by: Xun Jiang <[email protected]>
  • Loading branch information
Xun Jiang committed Jul 17, 2023
1 parent 55987c3 commit 4ae1fcf
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions pkg/cmd/cli/backup/logs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,24 @@ func TestNewLogsCommand(t *testing.T) {
case <-done:
}
})

t.Run("Invalid client test", func(t *testing.T) {
// create a factory
f := &factorymocks.Factory{}

kbClient := velerotest.NewFakeControllerRuntimeClient(t)

f.On("Namespace").Return(cmdtest.VeleroNameSpace)

c := NewLogsCommand(f)
assert.Equal(t, "Get backup logs", c.Short)

l := NewLogsOptions()
flags := new(flag.FlagSet)
l.BindFlags(flags)

f.On("KubebuilderClient").Return(kbClient, fmt.Errorf("test error"))
err := l.Complete([]string{""}, f)
require.Equal(t, "test error", err.Error())
})
}

0 comments on commit 4ae1fcf

Please sign in to comment.