(t *testing.T)
| 21 | ) |
| 22 | |
| 23 | func TestNewHTTPClient(t *testing.T) { |
| 24 | type args struct { |
| 25 | config refreshingConfig |
| 26 | appVersion string |
| 27 | invokingAgent string |
| 28 | logVerboseHTTP bool |
| 29 | skipDefaultHeaders bool |
| 30 | } |
| 31 | tests := []struct { |
| 32 | name string |
| 33 | args args |
| 34 | host string |
| 35 | wantHeader map[string][]string |
| 36 | wantStderr string |
| 37 | }{ |
| 38 | { |
| 39 | name: "github.com", |
| 40 | args: args{ |
| 41 | config: tinyConfig{"github.com:oauth_token": "MYTOKEN"}, |
| 42 | appVersion: "v1.2.3", |
| 43 | logVerboseHTTP: false, |
| 44 | }, |
| 45 | host: "github.com", |
| 46 | wantHeader: map[string][]string{ |
| 47 | "authorization": {"token MYTOKEN"}, |
| 48 | "user-agent": {"GitHub CLI v1.2.3"}, |
| 49 | "x-github-api-version": {"2022-11-28"}, |
| 50 | "accept": {"application/vnd.github.merge-info-preview+json, application/vnd.github.nebula-preview"}, |
| 51 | }, |
| 52 | wantStderr: "", |
| 53 | }, |
| 54 | { |
| 55 | name: "GHES", |
| 56 | args: args{ |
| 57 | config: tinyConfig{"example.com:oauth_token": "GHETOKEN"}, |
| 58 | appVersion: "v1.2.3", |
| 59 | }, |
| 60 | host: "example.com", |
| 61 | wantHeader: map[string][]string{ |
| 62 | "authorization": {"token GHETOKEN"}, |
| 63 | "user-agent": {"GitHub CLI v1.2.3"}, |
| 64 | "x-github-api-version": {"2022-11-28"}, |
| 65 | "accept": {"application/vnd.github.merge-info-preview+json, application/vnd.github.nebula-preview"}, |
| 66 | }, |
| 67 | wantStderr: "", |
| 68 | }, |
| 69 | { |
| 70 | name: "api_host is sent the token of the host it stands in for", |
| 71 | args: args{ |
| 72 | config: tinyConfig{ |
| 73 | "github.com:oauth_token": "MYTOKEN", |
| 74 | "api_host:gateway.internal": "github.com", |
| 75 | }, |
| 76 | appVersion: "v1.2.3", |
| 77 | }, |
| 78 | host: "gateway.internal", |
| 79 | wantHeader: map[string][]string{ |
| 80 | "authorization": {"token MYTOKEN"}, |
nothing calls this directly
no test coverage detected