MCPcopy
hub / github.com/cli/cli / setupMockOAuthConfig

Function setupMockOAuthConfig

pkg/cmd/agent-task/agent_task_test.go:15–33  ·  view source on GitHub ↗

setupMockOAuthConfig configures a blank config with a default host and optional token behavior.

(t *testing.T, tokenSource string)

Source from the content-addressed store, hash-verified

13
14// setupMockOAuthConfig configures a blank config with a default host and optional token behavior.
15func 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
35func TestNewCmdAgentTask(t *testing.T) {
36 tests := []struct {

Callers 2

TestNewCmdAgentTaskFunction · 0.85
TestAliasAreSetFunction · 0.85

Calls 3

NewBlankConfigFunction · 0.92
HelperMethod · 0.65
SetMethod · 0.65

Tested by

no test coverage detected