Skip to content

Commit

Permalink
Fix: JSON error check
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielHougaard committed Apr 17, 2024
1 parent bcb3eaa commit cb6cbaf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
10 changes: 8 additions & 2 deletions cli/test/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ func ExportSecrets(t *testing.T, authToken string, projectId string, envSlug str

var secrets []models.SingleEnvironmentVariable

json.Unmarshal(commandOutput.Bytes(), &secrets)
err := json.Unmarshal(commandOutput.Bytes(), &secrets)
if err != nil {
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.

Expand Down Expand Up @@ -68,7 +71,10 @@ func ExportSecretsWithoutImports(t *testing.T, authToken string, projectId strin

var secrets []models.SingleEnvironmentVariable

json.Unmarshal(commandOutput.Bytes(), &secrets)
err := json.Unmarshal(commandOutput.Bytes(), &secrets)
if err != nil {
t.Errorf("Error: %v", err)
}

assert.Len(t, secrets, len(DEV_SECRETS))

Expand Down
10 changes: 8 additions & 2 deletions cli/test/secrets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ func ListSecretsWithImportsAndRecursive(t *testing.T, authToken string, projectI

var secrets []models.SingleEnvironmentVariable

json.Unmarshal(commandOutput.Bytes(), &secrets)
err := json.Unmarshal(commandOutput.Bytes(), &secrets)
if err != nil {
t.Errorf("Error: %v", err)
}

if len(secrets) == 0 {
t.Errorf("No secrets found")
Expand Down Expand Up @@ -79,7 +82,10 @@ func GetSecretsByNames(t *testing.T, authToken string, projectId string, envSlug

var secrets []models.SingleEnvironmentVariable

json.Unmarshal(commandOutput.Bytes(), &secrets)
err := json.Unmarshal(commandOutput.Bytes(), &secrets)
if err != nil {
t.Errorf("Error: %v", err)
}

assert.Len(t, secrets, len(ALL_SECRETS))

Expand Down

0 comments on commit cb6cbaf

Please sign in to comment.