Skip to content

Commit

Permalink
applied review notes
Browse files Browse the repository at this point in the history
applied review notes
  • Loading branch information
alexey-kremsa-globant committed Apr 27, 2020
1 parent e9acbf5 commit c308919
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 14 deletions.
2 changes: 1 addition & 1 deletion pkg/apis/agones/v1/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
// Block of const Error messages
const (
ErrContainerRequired = "Container is required when using multiple containers in the pod template"
ErrHostPortDynamic = "HostPort cannot be specified with a Dynamic or Passthrough PortPolicy"
ErrHostPort = "HostPort cannot be specified with a Dynamic or Passthrough PortPolicy"
ErrPortPolicyStatic = "PortPolicy must be Static"
ErrContainerPortRequired = "ContainerPort must be defined for Dynamic and Static PortPolicies"
ErrContainerPortPassthrough = "ContainerPort cannot be specified with Passthrough PortPolicy"
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/agones/v1/gameserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ func (gss *GameServerSpec) Validate(devAddress string) ([]metav1.StatusCause, bo
causes = append(causes, metav1.StatusCause{
Type: metav1.CauseTypeFieldValueInvalid,
Field: fmt.Sprintf("%s.hostPort", p.Name),
Message: ErrHostPortDynamic,
Message: ErrHostPort,
})
}

Expand Down
29 changes: 18 additions & 11 deletions pkg/apis/agones/v1/gameserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,7 @@ func TestGameServerValidate(t *testing.T) {
}
}

func TestGameServerValidate_Features(t *testing.T) {
func TestGameServerValidateFeatures(t *testing.T) {
t.Parallel()
runtime.FeatureTestMutex.Lock()
defer runtime.FeatureTestMutex.Unlock()
Expand Down Expand Up @@ -1177,7 +1177,7 @@ func TestGameServerValidate_Features(t *testing.T) {
}
}

func TestGameServerPod_NoErrors(t *testing.T) {
func TestGameServerPodNoErrors(t *testing.T) {
t.Parallel()
fixture := defaultGameServer()
fixture.ApplyDefaults()
Expand Down Expand Up @@ -1498,12 +1498,15 @@ func TestGameServerIsBeforeReady(t *testing.T) {

func TestGameServerApplyToPodContainer(t *testing.T) {
t.Parallel()
type expected struct {
err string
tty bool
}

var testCases = []struct {
description string
gs *GameServer
errExpected string
ttyExpected bool
expected expected
}{
{
description: "OK, no error",
Expand All @@ -1520,8 +1523,10 @@ func TestGameServerApplyToPodContainer(t *testing.T) {
},
},
},
errExpected: "",
ttyExpected: true,
expected: expected{
err: "",
tty: true,
},
},
{
description: "container not found, error is returned",
Expand All @@ -1538,8 +1543,10 @@ func TestGameServerApplyToPodContainer(t *testing.T) {
},
},
},
errExpected: "failed to find container named mycontainer-WRONG-NAME in pod spec",
ttyExpected: false,
expected: expected{
err: "failed to find container named mycontainer-WRONG-NAME in pod spec",
tty: false,
},
},
}

Expand All @@ -1552,10 +1559,10 @@ func TestGameServerApplyToPodContainer(t *testing.T) {
return c
})

if tc.errExpected != "" && assert.NotNil(t, result) {
assert.Equal(t, tc.errExpected, result.Error())
if tc.expected.err != "" && assert.NotNil(t, result) {
assert.Equal(t, tc.expected.err, result.Error())
}
assert.Equal(t, tc.ttyExpected, pod.Spec.Containers[0].TTY)
assert.Equal(t, tc.expected.tty, pod.Spec.Containers[0].TTY)
assert.False(t, pod.Spec.Containers[1].TTY)
})
}
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/fleet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ func TestFleetGSSpecValidation(t *testing.T) {
statusErr, ok = err.(*k8serrors.StatusError)
assert.True(t, ok)
assert.Len(t, statusErr.Status().Details.Causes, 1)
assert.Equal(t, agonesv1.ErrHostPortDynamic, statusErr.Status().Details.Causes[0].Message)
assert.Equal(t, agonesv1.ErrHostPort, statusErr.Status().Details.Causes[0].Message)

fltPort.Spec.Template.Spec.Ports[0].PortPolicy = agonesv1.Static
fltPort.Spec.Template.Spec.Ports[0].HostPort = 0
Expand Down

0 comments on commit c308919

Please sign in to comment.