setupMockOAuthConfig configures a blank config with a default host and optional token behavior.
(t *testing.T, tokenSource string)
| 13 | |
| 14 | // setupMockOAuthConfig configures a blank config with a default host and optional token behavior. |
| 15 | func setupMockOAuthConfig(t *testing.T, tokenSource string) gh.Config { |
| 16 | t.Helper() |
| 17 | c := config.NewBlankConfig() |
| 18 | switch tokenSource { |
| 19 | case "oauth_token": |
| 20 | // valid OAuth device flow token stored in config |
| 21 | c.Set("github.com", "oauth_token", "gho_OAUTH123") |
| 22 | case "keyring": |
| 23 | // valid OAuth device flow token stored in keyring |
| 24 | c.Set("github.com", "oauth_token", "gho_OAUTH123") |
| 25 | case "GH_TOKEN": |
| 26 | // classic style token stored in config (will fail prefix check) |
| 27 | c.Set("github.com", "oauth_token", "ghp_CLASSIC123") |
| 28 | case "GH_ENTERPRISE_TOKEN": |
| 29 | // enterprise style token stored in config (will fail prefix check) |
| 30 | c.Set("something.ghes.com", "oauth_token", "ghe_ENTERPRISE123") |
| 31 | } |
| 32 | return c |
| 33 | } |
| 34 | |
| 35 | func TestNewCmdAgentTask(t *testing.T) { |
| 36 | tests := []struct { |
no test coverage detected