mirror of
https://github.com/holos-run/holos.git
synced 2026-03-20 09:15:02 +00:00
37 lines
906 B
Go
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)
|
|
}
|
|
})
|
|
}
|
|
}
|