MCPcopy Index your code
hub / github.com/cli/cli / TestNew_ServerURL_env

Function TestNew_ServerURL_env

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

Source from the content-addressed store, hash-verified

270}
271
272func TestNew_ServerURL_env(t *testing.T) {
273 t.Setenv("GITHUB_SERVER_URL", "https://mycompany.com")
274 t.Setenv("GITHUB_API_URL", "https://api.mycompany.com")
275 cfg := &ghmock.ConfigMock{
276 AuthenticationFunc: func() gh.AuthConfig {
277 return &config.AuthConfig{}
278 },
279 }
280 f := &cmdutil.Factory{
281 Config: func() (gh.Config, error) {
282 return cfg, nil
283 },
284 }
285 api := New(f)
286
287 if api.githubServer != "https://mycompany.com" {
288 t.Fatalf("expected https://mycompany.com, got %s", api.githubServer)
289 }
290 if len(cfg.AuthenticationCalls()) != 0 {
291 t.Fatalf("Configuration was checked instead of using the GITHUB_SERVER_URL environment variable")
292 }
293}
294
295func TestNew_ServerURL_dotcomFallback(t *testing.T) {
296 t.Setenv("GITHUB_SERVER_URL", "")

Callers

nothing calls this directly

Calls 2

AuthenticationCallsMethod · 0.95
NewFunction · 0.70

Tested by

no test coverage detected