MCPcopy Create free account
hub / github.com/cli/cli / TestNewHTTPClient

Function TestNewHTTPClient

api/http_client_test.go:23–269  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

21)
22
23func 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"},

Callers

nothing calls this directly

Calls 9

DoMethod · 0.95
TestFunction · 0.92
NewHTTPClientFunction · 0.85
normalizeVerboseLogFunction · 0.85
EqualMethod · 0.80
CloseMethod · 0.65
RunMethod · 0.65
SetMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected