Skip to content

Commit

Permalink
fix: cleanup unit tests
Browse files Browse the repository at this point in the history
Signed-off-by: hari rongali <[email protected]>
  • Loading branch information
harikrongali committed May 14, 2021
1 parent 6e1c915 commit fbd0591
Showing 1 changed file with 1 addition and 51 deletions.
52 changes: 1 addition & 51 deletions pkg/kubectl-argo-rollouts/cmd/promote/promote_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,56 +144,6 @@ func TestPromoteCmdSuccesSkipAllSteps(t *testing.T) {
assert.Empty(t, stderr)
}

func TestPromoteCmdSuccesFirstStepWithDefaultPromote(t *testing.T) {
ro := v1alpha1.Rollout{
ObjectMeta: metav1.ObjectMeta{
Name: "guestbook",
Namespace: metav1.NamespaceDefault,
},
Spec: v1alpha1.RolloutSpec{
Strategy: v1alpha1.RolloutStrategy{
Canary: &v1alpha1.CanaryStrategy{
Steps: []v1alpha1.CanaryStep{
{
SetWeight: pointer.Int32Ptr(1),
},
{
SetWeight: pointer.Int32Ptr(2),
},
},
},
},
},
}

tf, o := options.NewFakeArgoRolloutsOptions(&ro)
defer tf.Cleanup()
fakeClient := o.RolloutsClient.(*fakeroclient.Clientset)
fakeClient.PrependReactor("patch", "*", func(action kubetesting.Action) (handled bool, ret runtime.Object, err error) {
if patchAction, ok := action.(kubetesting.PatchAction); ok {
patchRo := v1alpha1.Rollout{}
err := json.Unmarshal(patchAction.GetPatch(), &patchRo)
if err != nil {
panic(err)
}
ro.Status.CurrentStepIndex = patchRo.Status.CurrentStepIndex
}
return true, &ro, nil
})

cmd := NewCmdPromote(o)
cmd.PersistentPreRunE = o.PersistentPreRunE
cmd.SetArgs([]string{"guestbook"})

err := cmd.Execute()
assert.Nil(t, err)
assert.Equal(t, int32(1), *ro.Status.CurrentStepIndex)
stdout := o.Out.(*bytes.Buffer).String()
stderr := o.ErrOut.(*bytes.Buffer).String()
assert.Equal(t, stdout, "rollout 'guestbook' promoted\n")
assert.Empty(t, stderr)
}

func TestPromoteCmdSuccesFirstStep(t *testing.T) {
ro := v1alpha1.Rollout{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -233,7 +183,7 @@ func TestPromoteCmdSuccesFirstStep(t *testing.T) {

cmd := NewCmdPromote(o)
cmd.PersistentPreRunE = o.PersistentPreRunE
cmd.SetArgs([]string{"guestbook"})
cmd.SetArgs([]string{"guestbook", "-c"})

err := cmd.Execute()
assert.Nil(t, err)
Expand Down

0 comments on commit fbd0591

Please sign in to comment.