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

Function TestNew_APIURL_env

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

Source from the content-addressed store, hash-verified

185}
186
187func TestNew_APIURL_env(t *testing.T) {
188 t.Setenv("GITHUB_API_URL", "https://api.mycompany.com")
189 t.Setenv("GITHUB_SERVER_URL", "https://mycompany.com")
190 cfg := &ghmock.ConfigMock{
191 AuthenticationFunc: func() gh.AuthConfig {
192 return &config.AuthConfig{}
193 },
194 }
195 f := &cmdutil.Factory{
196 Config: func() (gh.Config, error) {
197 return cfg, nil
198 },
199 }
200 api := New(f)
201
202 if api.githubAPI != "https://api.mycompany.com" {
203 t.Fatalf("expected https://api.mycompany.com, got %s", api.githubAPI)
204 }
205 if len(cfg.AuthenticationCalls()) != 0 {
206 t.Fatalf("Configuration was checked instead of using the GITHUB_API_URL environment variable")
207 }
208}
209
210func TestNew_APIURL_dotcomFallback(t *testing.T) {
211 t.Setenv("GITHUB_API_URL", "")

Callers

nothing calls this directly

Calls 2

AuthenticationCallsMethod · 0.95
NewFunction · 0.70

Tested by

no test coverage detected