From c56b5b56a137b5b20c8f8db0d7bce45f1295f946 Mon Sep 17 00:00:00 2001 From: Girish Ramnani Date: Mon, 24 Aug 2020 22:18:23 +0530 Subject: [PATCH] add json output test for preference view (#3806) * add json output test for preference view * failing intg test * add a before each to use a fresh preference --- tests/integration/cmd_pref_config_test.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/integration/cmd_pref_config_test.go b/tests/integration/cmd_pref_config_test.go index 595f0e73a..342239b85 100644 --- a/tests/integration/cmd_pref_config_test.go +++ b/tests/integration/cmd_pref_config_test.go @@ -76,6 +76,14 @@ var _ = Describe("odo preference and config command tests", func() { }) Context("When configuring global config values", func() { + JustBeforeEach(func() { + context = helper.CreateNewContext() + os.Setenv("GLOBALODOCONFIG", filepath.Join(context, "preference.yaml")) + }) + JustAfterEach(func() { + helper.DeleteDir(context) + os.Unsetenv("GLOBALODOCONFIG") + }) It("should successfully updated", func() { helper.CmdShouldPass("odo", "preference", "set", "updatenotification", "false") helper.CmdShouldPass("odo", "preference", "set", "timeout", "5") @@ -103,6 +111,15 @@ var _ = Describe("odo preference and config command tests", func() { helper.CmdShouldFail("odo", "preference", "set", "-f", "experimental", "invalid-value") helper.CmdShouldFail("odo", "preference", "set", "-f", "updatenotification", "invalid-value") }) + + It("should show json output", func() { + prefJSONOutput, err := helper.Unindented(helper.CmdShouldPass("odo", "preference", "view", "-o", "json")) + Expect(err).Should(BeNil()) + expected, err := helper.Unindented(`{"kind":"PreferenceList","apiVersion":"odo.dev/v1alpha1","items":[{"Name":"UpdateNotification","Value":null,"Default":true,"Type":"bool","Description":"Flag to control if an update notification is shown or not (Default: true)"},{"Name":"NamePrefix","Value":null,"Default":"","Type":"string","Description":"Use this value to set a default name prefix (Default: current directory name)"},{"Name":"Timeout","Value":null,"Default":1,"Type":"int","Description":"Timeout (in seconds) for OpenShift server connection check (Default: 1)"},{"Name":"BuildTimeout","Value":null,"Default":300,"Type":"int","Description":"BuildTimeout (in seconds) for waiting for a build of the git component to complete (Default: 300)"},{"Name":"PushTimeout","Value":null,"Default":240,"Type":"int","Description":"PushTimeout (in seconds) for waiting for a Pod to come up (Default: 240)"},{"Name":"Experimental","Value":null,"Default":false,"Type":"bool","Description":"Set this value to true to expose features in development/experimental mode"},{"Name":"PushTarget","Value":null,"Default":"kube","Type":"string","Description":"Set this value to 'kube' or 'docker' to tell odo where to push applications to. (Default: kube)"}]}`) + Expect(err).Should(BeNil()) + Expect(prefJSONOutput).Should(MatchJSON(expected)) + }) + }) Context("when creating odo local config in the same config dir", func() {