@@ -25,30 +25,34 @@ func createMockAPIServer(t *testing.T, licenseToken string) *httptest.Server {
2525 switch {
2626 case r .Method == "POST" && r .URL .Path == "/v1/auth/request" :
2727 w .WriteHeader (http .StatusCreated )
28- json .NewEncoder (w ).Encode (map [string ]string {
28+ err := json .NewEncoder (w ).Encode (map [string ]string {
2929 "id" : authReqID ,
3030 "code" : "TEST123" ,
3131 "exchange_token" : exchangeToken ,
3232 })
33+ require .NoError (t , err )
3334
3435 case r .Method == "GET" && r .URL .Path == fmt .Sprintf ("/v1/auth/request/%s" , authReqID ):
3536 w .WriteHeader (http .StatusOK )
36- json .NewEncoder (w ).Encode (map [string ]bool {
37+ err := json .NewEncoder (w ).Encode (map [string ]bool {
3738 "confirmed" : true ,
3839 })
40+ require .NoError (t , err )
3941
4042 case r .Method == "POST" && r .URL .Path == fmt .Sprintf ("/v1/auth/request/%s/exchange" , authReqID ):
4143 w .WriteHeader (http .StatusOK )
42- json .NewEncoder (w ).Encode (map [string ]string {
44+ err := json .NewEncoder (w ).Encode (map [string ]string {
4345 "id" : authReqID ,
4446 "auth_token" : bearerToken ,
4547 })
48+ require .NoError (t , err )
4649
4750 case r .Method == "GET" && r .URL .Path == "/v1/license/credentials" :
4851 w .WriteHeader (http .StatusOK )
49- json .NewEncoder (w ).Encode (map [string ]string {
52+ err := json .NewEncoder (w ).Encode (map [string ]string {
5053 "token" : licenseToken ,
5154 })
55+ require .NoError (t , err )
5256
5357 default :
5458 t .Logf ("Unhandled request: %s %s" , r .Method , r .URL .Path )
@@ -81,7 +85,7 @@ func TestDeviceFlowSuccess(t *testing.T) {
8185 // Keep stdin open and get the pipe to simulate ENTER
8286 stdinPipe , err := cmd .StdinPipe ()
8387 require .NoError (t , err )
84- defer stdinPipe .Close ()
88+ defer func () { _ = stdinPipe .Close () } ()
8589
8690 outputCh := make (chan []byte , 1 )
8791 go func () {
@@ -140,7 +144,7 @@ func TestDeviceFlowFailure_RequestNotConfirmed(t *testing.T) {
140144 // Keep stdin open and get the pipe to simulate ENTER
141145 stdinPipe , err := cmd .StdinPipe ()
142146 require .NoError (t , err )
143- defer stdinPipe .Close ()
147+ defer func () { _ = stdinPipe .Close () } ()
144148
145149 outputCh := make (chan []byte , 1 )
146150 go func () {
0 commit comments