Files
holos/internal/cli/preflight/gh_test.go
Jeff McCune 4184619afc (#126) Refactor pkg to internal
pkg folder is not needed.  Move everything internal for now.
2024-04-12 13:56:16 -07:00

37 lines
906 B
Go

package preflight
import "testing"
func TestGhTokenAllowsRepoCreation(t *testing.T) {
testCases := []struct {
name string
status ghAuthStatusResponse
expected bool
}{
{
name: "token has necessary scopes",
status: "- Token: gho_************************************\n- Token scopes: 'gist', 'read:org', 'repo'",
expected: true,
},
{
name: "token has necessary scopes",
status: " - Token scopes: 'gist', 'read:org', 'repo'",
expected: true,
},
{
name: "token does not have necessary scopes",
status: "- Token: gho_************************************\n- Token scopes: 'gist', 'read:org'",
expected: false,
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
result := ghTokenAllowsRepoCreation(tc.status)
if result != tc.expected {
t.Errorf("expected %v, got %v", tc.expected, result)
}
})
}
}