Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing improvements for multiple action secrets, dependencies #852

Merged
merged 3 commits into from
Sep 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 46 additions & 15 deletions internal/cli/actions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ func TestActionsPickerOptions(t *testing.T) {
})
}
}

func TestActionsInputSecretsToActionSecrets(t *testing.T) {
t.Run("it should map input secrets to action payload", func(t *testing.T) {
input := map[string]string{
Expand All @@ -218,22 +219,20 @@ func TestActionsInputSecretsToActionSecrets(t *testing.T) {
"secret3": "value3",
}
res := inputSecretsToActionSecrets(input)
expected := []management.ActionSecret{
{
Name: auth0.String("secret1"),
Value: auth0.String("value1"),
},
{
Name: auth0.String("secret2"),
Value: auth0.String("value2"),
},
{
Name: auth0.String("secret3"),
Value: auth0.String("value3"),
},
}

assert.Len(t, *res, 3)
assert.Equal(t, *res, expected)
assert.Contains(t, *res, management.ActionSecret{
Name: auth0.String("secret1"),
Value: auth0.String("value1"),
})
assert.Contains(t, *res, management.ActionSecret{
Name: auth0.String("secret2"),
Value: auth0.String("value2"),
})
assert.Contains(t, *res, management.ActionSecret{
Name: auth0.String("secret3"),
Value: auth0.String("value3"),
})
})

t.Run("it should handle empty input secrets", func(t *testing.T) {
Expand All @@ -244,3 +243,35 @@ func TestActionsInputSecretsToActionSecrets(t *testing.T) {
assert.Equal(t, res, &expected)
})
}
func TestActionsInputDependenciesToActionDependencies(t *testing.T) {
t.Run("it should map input dependencies to action payload", func(t *testing.T) {
input := map[string]string{
"fs-extra": "11.1.1",
"lodash": "4.0.0",
"uuid": "9.0.0",
}
res := inputDependenciesToActionDependencies(input)

assert.Len(t, *res, 3)
assert.Contains(t, *res, management.ActionDependency{
Name: auth0.String("fs-extra"),
Version: auth0.String("11.1.1"),
})
assert.Contains(t, *res, management.ActionDependency{
Name: auth0.String("lodash"),
Version: auth0.String("4.0.0"),
})
assert.Contains(t, *res, management.ActionDependency{
Name: auth0.String("uuid"),
Version: auth0.String("9.0.0"),
})
})

t.Run("it should handle empty input dependencies", func(t *testing.T) {
emptyInput := map[string]string{}
res := inputDependenciesToActionDependencies(emptyInput)
expected := []management.ActionDependency{}
assert.Len(t, *res, 0)
assert.Equal(t, expected, *res)
})
}
Loading