MCPcopy
hub / github.com/cli/cli / TestNew_ServerURL_customConfig

Function TestNew_ServerURL_customConfig

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

Source from the content-addressed store, hash-verified

245}
246
247func TestNew_ServerURL_customConfig(t *testing.T) {
248 t.Setenv("GITHUB_SERVER_URL", "")
249 t.Setenv("GITHUB_API_URL", "https://github.mycompany.com/api/v3")
250 cfg := &ghmock.ConfigMock{
251 AuthenticationFunc: func() gh.AuthConfig {
252 authCfg := &config.AuthConfig{}
253 authCfg.SetDefaultHost("github.mycompany.com", "GH_HOST")
254 return authCfg
255 },
256 }
257 f := &cmdutil.Factory{
258 Config: func() (gh.Config, error) {
259 return cfg, nil
260 },
261 }
262 api := New(f)
263
264 if api.githubServer != "https://github.mycompany.com" {
265 t.Fatalf("expected https://github.mycompany.com, got %s", api.githubServer)
266 }
267 if len(cfg.AuthenticationCalls()) != 1 {
268 t.Fatalf("Server url was not pulled from the config")
269 }
270}
271
272func TestNew_ServerURL_env(t *testing.T) {
273 t.Setenv("GITHUB_SERVER_URL", "https://mycompany.com")

Callers

nothing calls this directly

Calls 3

SetDefaultHostMethod · 0.95
AuthenticationCallsMethod · 0.95
NewFunction · 0.70

Tested by

no test coverage detected