Skip to content

Commit

Permalink
Test case of status
Browse files Browse the repository at this point in the history
Signed-off-by: Feny Mehta <[email protected]>
  • Loading branch information
fbm3307 committed Nov 12, 2024
1 parent 857fdc9 commit 760cf0c
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions pkg/cmd/adm/restart_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ func TestOperator(t *testing.T) {
return nil
}, func(ctx *clicontext.CommandContext, deployment appsv1.Deployment, f cmdutil.Factory, ioStreams genericclioptions.IOStreams) error {
require.Equal(t, testIOStreams, ioStreams)
require.Equal(t, nil, f)
require.Nil(t, f)
return nil
})

Expand All @@ -303,11 +303,11 @@ func TestOperator(t *testing.T) {
err := restartDeployment(ctx, fakeClient, "toolchain-host-operator", nil, testIOStreams,
func(ctx *clicontext.CommandContext, f cmdutil.Factory, ioStreams genericclioptions.IOStreams, labelSelector string) error {
require.Equal(t, testIOStreams, ioStreams)
require.Equal(t, nil, f)
require.Nil(t, f)
return nil
}, func(ctx *clicontext.CommandContext, deployment appsv1.Deployment, f cmdutil.Factory, ioStreams genericclioptions.IOStreams) error {
require.Equal(t, testIOStreams, ioStreams)
require.Equal(t, nil, f)
require.Nil(t, f)
return expectedErr
})

Expand Down Expand Up @@ -346,6 +346,21 @@ func TestOperator(t *testing.T) {
require.EqualError(t, err, expectedErr.Error())
})

t.Run("error in rollout status of the Non operator deployments", func(t *testing.T) {
//given
newClient, fakeClient := NewFakeClients(t, toolchainCluster, hostDeployment, regServDeployment)
ctx := clicontext.NewCommandContext(term, newClient)
expectedErr := fmt.Errorf("Could not check the status of the deployment")
//when
err := restartDeployment(ctx, fakeClient, "toolchain-host-operator", nil, genericclioptions.NewTestIOStreamsDiscard(),
func(ctx *clicontext.CommandContext, f cmdutil.Factory, ioStreams genericclioptions.IOStreams, labelSelector string) error {
return expectedErr
}, nil)

//then
require.EqualError(t, err, expectedErr.Error())
})

t.Run("autoscalling deployment should not restart", func(t *testing.T) {
//given
newClient, fakeClient := NewFakeClients(t, toolchainCluster, memberDeployment, autoscalarDeployment)
Expand Down

0 comments on commit 760cf0c

Please sign in to comment.