@@ -31,6 +31,7 @@ func Test_NewCmdApi(t *testing.T) {
3131 name : "no flags" ,
3232 cli : "graphql" ,
3333 wants : ApiOptions {
34+ Hostname : "" ,
3435 RequestMethod : "GET" ,
3536 RequestMethodPassed : false ,
3637 RequestPath : "graphql" ,
@@ -48,6 +49,7 @@ func Test_NewCmdApi(t *testing.T) {
4849 name : "override method" ,
4950 cli : "repos/octocat/Spoon-Knife -XDELETE" ,
5051 wants : ApiOptions {
52+ Hostname : "" ,
5153 RequestMethod : "DELETE" ,
5254 RequestMethodPassed : true ,
5355 RequestPath : "repos/octocat/Spoon-Knife" ,
@@ -65,6 +67,7 @@ func Test_NewCmdApi(t *testing.T) {
6567 name : "with fields" ,
6668 cli : "graphql -f query=QUERY -F body=@file.txt" ,
6769 wants : ApiOptions {
70+ Hostname : "" ,
6871 RequestMethod : "GET" ,
6972 RequestMethodPassed : false ,
7073 RequestPath : "graphql" ,
@@ -82,6 +85,7 @@ func Test_NewCmdApi(t *testing.T) {
8285 name : "with headers" ,
8386 cli : "user -H 'accept: text/plain' -i" ,
8487 wants : ApiOptions {
88+ Hostname : "" ,
8589 RequestMethod : "GET" ,
8690 RequestMethodPassed : false ,
8791 RequestPath : "user" ,
@@ -99,6 +103,7 @@ func Test_NewCmdApi(t *testing.T) {
99103 name : "with pagination" ,
100104 cli : "repos/OWNER/REPO/issues --paginate" ,
101105 wants : ApiOptions {
106+ Hostname : "" ,
102107 RequestMethod : "GET" ,
103108 RequestMethodPassed : false ,
104109 RequestPath : "repos/OWNER/REPO/issues" ,
@@ -116,6 +121,7 @@ func Test_NewCmdApi(t *testing.T) {
116121 name : "with silenced output" ,
117122 cli : "repos/OWNER/REPO/issues --silent" ,
118123 wants : ApiOptions {
124+ Hostname : "" ,
119125 RequestMethod : "GET" ,
120126 RequestMethodPassed : false ,
121127 RequestPath : "repos/OWNER/REPO/issues" ,
@@ -138,6 +144,7 @@ func Test_NewCmdApi(t *testing.T) {
138144 name : "GraphQL pagination" ,
139145 cli : "-XPOST graphql --paginate" ,
140146 wants : ApiOptions {
147+ Hostname : "" ,
141148 RequestMethod : "POST" ,
142149 RequestMethodPassed : true ,
143150 RequestPath : "graphql" ,
@@ -160,6 +167,7 @@ func Test_NewCmdApi(t *testing.T) {
160167 name : "with request body from file" ,
161168 cli : "user --input myfile" ,
162169 wants : ApiOptions {
170+ Hostname : "" ,
163171 RequestMethod : "GET" ,
164172 RequestMethodPassed : false ,
165173 RequestPath : "user" ,
@@ -178,10 +186,29 @@ func Test_NewCmdApi(t *testing.T) {
178186 cli : "" ,
179187 wantsErr : true ,
180188 },
189+ {
190+ name : "with hostname" ,
191+ cli : "graphql --hostname tom.petty" ,
192+ wants : ApiOptions {
193+ Hostname : "tom.petty" ,
194+ RequestMethod : "GET" ,
195+ RequestMethodPassed : false ,
196+ RequestPath : "graphql" ,
197+ RequestInputFile : "" ,
198+ RawFields : []string (nil ),
199+ MagicFields : []string (nil ),
200+ RequestHeaders : []string (nil ),
201+ ShowResponseHeaders : false ,
202+ Paginate : false ,
203+ Silent : false ,
204+ },
205+ wantsErr : false ,
206+ },
181207 }
182208 for _ , tt := range tests {
183209 t .Run (tt .name , func (t * testing.T ) {
184210 cmd := NewCmdApi (f , func (o * ApiOptions ) error {
211+ assert .Equal (t , tt .wants .Hostname , o .Hostname )
185212 assert .Equal (t , tt .wants .RequestMethod , o .RequestMethod )
186213 assert .Equal (t , tt .wants .RequestMethodPassed , o .RequestMethodPassed )
187214 assert .Equal (t , tt .wants .RequestPath , o .RequestPath )
0 commit comments