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

Function TestNewHTTPClient

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

Source from the content-addressed store, hash-verified

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