MCPcopy
hub / github.com/cli/cli / TestNew_APIURL_customConfig

Function TestNew_APIURL_customConfig

internal/codespaces/api/api_test.go:162–185  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

160}
161
162func TestNew_APIURL_customConfig(t *testing.T) {
163 t.Setenv("GITHUB_API_URL", "")
164 t.Setenv("GITHUB_SERVER_URL", "https://github.mycompany.com")
165 cfg := &ghmock.ConfigMock{
166 AuthenticationFunc: func() gh.AuthConfig {
167 authCfg := &config.AuthConfig{}
168 authCfg.SetDefaultHost("github.mycompany.com", "GH_HOST")
169 return authCfg
170 },
171 }
172 f := &cmdutil.Factory{
173 Config: func() (gh.Config, error) {
174 return cfg, nil
175 },
176 }
177 api := New(f)
178
179 if api.githubAPI != "https://github.mycompany.com/api/v3" {
180 t.Fatalf("expected https://github.mycompany.com/api/v3, got %s", api.githubAPI)
181 }
182 if len(cfg.AuthenticationCalls()) != 1 {
183 t.Fatalf("API url was not pulled from the config")
184 }
185}
186
187func TestNew_APIURL_env(t *testing.T) {
188 t.Setenv("GITHUB_API_URL", "https://api.mycompany.com")

Callers

nothing calls this directly

Calls 3

SetDefaultHostMethod · 0.95
AuthenticationCallsMethod · 0.95
NewFunction · 0.70

Tested by

no test coverage detected