From 5ed3681ca3c7d92eff02a18edd29766c5ee92bd3 Mon Sep 17 00:00:00 2001 From: Alexey Kremsa Date: Tue, 31 Mar 2020 17:29:53 +0300 Subject: [PATCH] Fixed out of range error in e2e TestFleetGSSpecValidation --- test/e2e/fleet_test.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/test/e2e/fleet_test.go b/test/e2e/fleet_test.go index 7fc17376c0..bff6c76e18 100644 --- a/test/e2e/fleet_test.go +++ b/test/e2e/fleet_test.go @@ -586,22 +586,24 @@ func TestFleetGSSpecValidation(t *testing.T) { assert.NotNil(t, err) statusErr, ok := err.(*k8serrors.StatusError) assert.True(t, ok) - assert.Len(t, statusErr.Status().Details.Causes, 2) + if assert.Len(t, statusErr.Status().Details.Causes, 2) { + assert.Equal(t, "Container must be empty or the name of a container in the pod template", statusErr.Status().Details.Causes[1].Message) + } assert.Equal(t, metav1.CauseTypeFieldValueInvalid, statusErr.Status().Details.Causes[0].Type) assert.Equal(t, "Could not find a container named testing", statusErr.Status().Details.Causes[0].Message) - assert.Equal(t, "Container must be empty or the name of a container in the pod template", statusErr.Status().Details.Causes[1].Message) flt.Spec.Template.Spec.Container = "" _, err = client.Fleets(defaultNs).Create(flt) assert.NotNil(t, err) statusErr, ok = err.(*k8serrors.StatusError) assert.True(t, ok) - assert.Len(t, statusErr.Status().Details.Causes, 2) CausesMessages := []string{agonesv1.ErrContainerRequired, "Could not find a container named "} + if assert.Len(t, statusErr.Status().Details.Causes, 2) { + assert.Equal(t, metav1.CauseTypeFieldValueInvalid, statusErr.Status().Details.Causes[1].Type) + assert.Contains(t, CausesMessages, statusErr.Status().Details.Causes[1].Message) + } assert.Equal(t, metav1.CauseTypeFieldValueInvalid, statusErr.Status().Details.Causes[0].Type) assert.Contains(t, CausesMessages, statusErr.Status().Details.Causes[0].Message) - assert.Equal(t, metav1.CauseTypeFieldValueInvalid, statusErr.Status().Details.Causes[1].Type) - assert.Contains(t, CausesMessages, statusErr.Status().Details.Causes[1].Message) // use valid name for a container, one of two defined above flt.Spec.Template.Spec.Container = containerName