From b598dd3d477ff1d95f8f9eaa079c5a18cbeecb0a Mon Sep 17 00:00:00 2001 From: Daniel Hougaard <62331820+DanielHougaard@users.noreply.github.com> Date: Thu, 18 Apr 2024 14:59:41 +0200 Subject: [PATCH] Feat: Cli integration tests -- exports --- cli/test/export_test.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cli/test/export_test.go b/cli/test/export_test.go index dd156fc39..a0f68fa7a 100644 --- a/cli/test/export_test.go +++ b/cli/test/export_test.go @@ -16,8 +16,9 @@ func ExportSecrets(t *testing.T, authToken string, projectId string, envSlug str rootCommand := cmd.NewRootCmd() commandOutput := new(bytes.Buffer) + errorOutput := new(bytes.Buffer) rootCommand.SetOut(commandOutput) - rootCommand.SetErr(commandOutput) + rootCommand.SetErr(errorOutput) args := []string{ "export", @@ -25,6 +26,7 @@ func ExportSecrets(t *testing.T, authToken string, projectId string, envSlug str args = append(args, fmt.Sprintf("--token=%s", authToken)) args = append(args, fmt.Sprintf("--projectId=%s", projectId)) + args = append(args, fmt.Sprintf("--env=%s", envSlug)) rootCommand.SetArgs(args) rootCommand.Execute() @@ -36,7 +38,7 @@ func ExportSecrets(t *testing.T, authToken string, projectId string, envSlug str t.Errorf("Error: %v", err) } - expectedLength := len(ALL_SECRETS) - 1 // -1 because the default path is "/", and the secret in /folder will not be found. + expectedLength := len(DEV_SECRETS) + len(STAGING_SECRETS) assert.Len(t, secrets, expectedLength) @@ -47,7 +49,6 @@ func ExportSecrets(t *testing.T, authToken string, projectId string, envSlug str assert.Contains(t, ALL_SECRET_KEYS, secret.Key) assert.Contains(t, ALL_SECRET_VALUES, secret.Value) } - } func ExportSecretsWithoutImports(t *testing.T, authToken string, projectId string, envSlug string) { @@ -64,6 +65,7 @@ func ExportSecretsWithoutImports(t *testing.T, authToken string, projectId strin args = append(args, fmt.Sprintf("--token=%s", authToken)) args = append(args, fmt.Sprintf("--projectId=%s", projectId)) + args = append(args, fmt.Sprintf("--env=%s", envSlug)) args = append(args, "--include-imports=false") rootCommand.SetArgs(args)