Skip to content

Commit 4debbb1

Browse files
committed
Further separate out test cases
1 parent 3a55c26 commit 4debbb1

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

pkg/cmd/factory/http_test.go

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,37 +46,53 @@ func TestNewHTTPClient(t *testing.T) {
4646
{
4747
name: "github.com no Accept header",
4848
args: args{
49-
config: tinyConfig{"example.com:oauth_token": "MYTOKEN"},
49+
config: tinyConfig{"github.com:oauth_token": "MYTOKEN"},
5050
appVersion: "v1.2.3",
5151
setAccept: false,
5252
},
5353
host: "github.com",
5454
wantHeader: map[string]string{
55-
"authorization": "",
55+
"authorization": "token MYTOKEN",
5656
"user-agent": "GitHub CLI v1.2.3",
5757
"accept": "",
5858
},
5959
wantStderr: "",
6060
},
61+
{
62+
name: "github.com no authentication token",
63+
args: args{
64+
config: tinyConfig{"example.com:oauth_token": "MYTOKEN"},
65+
appVersion: "v1.2.3",
66+
setAccept: true,
67+
},
68+
host: "github.com",
69+
wantHeader: map[string]string{
70+
"authorization": "",
71+
"user-agent": "GitHub CLI v1.2.3",
72+
"accept": "application/vnd.github.merge-info-preview+json",
73+
},
74+
wantStderr: "",
75+
},
6176
{
6277
name: "github.com in verbose mode",
6378
args: args{
6479
config: tinyConfig{"github.com:oauth_token": "MYTOKEN"},
6580
appVersion: "v1.2.3",
66-
setAccept: false,
81+
setAccept: true,
6782
},
6883
host: "github.com",
6984
envDebug: "api",
7085
wantHeader: map[string]string{
7186
"authorization": "token MYTOKEN",
7287
"user-agent": "GitHub CLI v1.2.3",
73-
"accept": "",
88+
"accept": "application/vnd.github.merge-info-preview+json",
7489
},
7590
wantStderr: heredoc.Doc(`
7691
* Request at <time>
7792
* Request to http://<host>:<port>
7893
> GET / HTTP/1.1
7994
> Host: github.com
95+
> Accept: application/vnd.github.merge-info-preview+json
8096
> Authorization: token ████████████████████
8197
> User-Agent: GitHub CLI v1.2.3
8298

0 commit comments

Comments
 (0)