From e88a873b2738a99aaecb25cdb6094f75aa5d657b Mon Sep 17 00:00:00 2001 From: David Simansky Date: Wed, 5 Feb 2020 18:50:31 +0100 Subject: [PATCH] Add e2e test for cmd and arg options (#637) --- test/e2e/service_options_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/e2e/service_options_test.go b/test/e2e/service_options_test.go index 4d621603a..e1acb58f4 100644 --- a/test/e2e/service_options_test.go +++ b/test/e2e/service_options_test.go @@ -87,6 +87,15 @@ func TestServiceOptions(t *testing.T) { test.validateAutoscaleWindow(t, "svc4", "15s") 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) { @@ -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) +}