Add e2e test for cmd and arg options (#637)

This commit is contained in:
David Simansky 2020-02-05 18:50:31 +01:00 committed by GitHub
parent ffdeafe33e
commit e88a873b27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 0 deletions

View File

@ -87,6 +87,15 @@ func TestServiceOptions(t *testing.T) {
test.validateAutoscaleWindow(t, "svc4", "15s") test.validateAutoscaleWindow(t, "svc4", "15s")
test.serviceDelete(t, "svc4") test.serviceDelete(t, "svc4")
}) })
t.Run("create, update and validate service with cmd and arg options", func(t *testing.T) {
test.serviceCreateWithOptions(t, "svc5", []string{"--cmd", "/go/bin/helloworld"})
test.validateContainerField(t, "svc5", "command", "[/go/bin/helloworld]")
test.serviceUpdate(t, "svc5", []string{"--arg", "myArg1", "--arg", "--myArg2"})
test.validateContainerField(t, "svc5", "args", "[myArg1 --myArg2]")
test.serviceUpdate(t, "svc5", []string{"--arg", "myArg1"})
test.validateContainerField(t, "svc5", "args", "[myArg1]")
})
} }
func (test *e2eTest) serviceCreateWithOptions(t *testing.T, serviceName string, options []string) { func (test *e2eTest) serviceCreateWithOptions(t *testing.T, serviceName string, options []string) {
@ -191,3 +200,10 @@ func (test *e2eTest) validateServiceAnnotations(t *testing.T, serviceName string
} }
} }
} }
func (test *e2eTest) validateContainerField(t *testing.T, serviceName, field, expected string) {
jsonpath := fmt.Sprintf("jsonpath={.items[0].spec.template.spec.containers[0].%s}", field)
out, err := test.kn.RunWithOpts([]string{"service", "list", serviceName, "-o", jsonpath}, runOpts{})
assert.NilError(t, err)
assert.Equal(t, out, expected)
}