(t *testing.T)
| 160 | } |
| 161 | |
| 162 | func 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 | |
| 187 | func TestNew_APIURL_env(t *testing.T) { |
| 188 | t.Setenv("GITHUB_API_URL", "https://api.mycompany.com") |
nothing calls this directly
no test coverage detected