mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-03 17:26:07 +00:00
Feat: Cli integration tests -- exports
This commit is contained in:
@@ -16,8 +16,9 @@ func ExportSecrets(t *testing.T, authToken string, projectId string, envSlug str
|
|||||||
rootCommand := cmd.NewRootCmd()
|
rootCommand := cmd.NewRootCmd()
|
||||||
|
|
||||||
commandOutput := new(bytes.Buffer)
|
commandOutput := new(bytes.Buffer)
|
||||||
|
errorOutput := new(bytes.Buffer)
|
||||||
rootCommand.SetOut(commandOutput)
|
rootCommand.SetOut(commandOutput)
|
||||||
rootCommand.SetErr(commandOutput)
|
rootCommand.SetErr(errorOutput)
|
||||||
|
|
||||||
args := []string{
|
args := []string{
|
||||||
"export",
|
"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("--token=%s", authToken))
|
||||||
args = append(args, fmt.Sprintf("--projectId=%s", projectId))
|
args = append(args, fmt.Sprintf("--projectId=%s", projectId))
|
||||||
|
args = append(args, fmt.Sprintf("--env=%s", envSlug))
|
||||||
|
|
||||||
rootCommand.SetArgs(args)
|
rootCommand.SetArgs(args)
|
||||||
rootCommand.Execute()
|
rootCommand.Execute()
|
||||||
@@ -36,7 +38,7 @@ func ExportSecrets(t *testing.T, authToken string, projectId string, envSlug str
|
|||||||
t.Errorf("Error: %v", err)
|
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)
|
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_KEYS, secret.Key)
|
||||||
assert.Contains(t, ALL_SECRET_VALUES, secret.Value)
|
assert.Contains(t, ALL_SECRET_VALUES, secret.Value)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func ExportSecretsWithoutImports(t *testing.T, authToken string, projectId string, envSlug string) {
|
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("--token=%s", authToken))
|
||||||
args = append(args, fmt.Sprintf("--projectId=%s", projectId))
|
args = append(args, fmt.Sprintf("--projectId=%s", projectId))
|
||||||
|
args = append(args, fmt.Sprintf("--env=%s", envSlug))
|
||||||
args = append(args, "--include-imports=false")
|
args = append(args, "--include-imports=false")
|
||||||
|
|
||||||
rootCommand.SetArgs(args)
|
rootCommand.SetArgs(args)
|
||||||
|
|||||||
Reference in New Issue
Block a user