Skip to content

Commit e60d58a

Browse files
committed
fix: suppress unused return value from json encoder in tests
1 parent bbb6184 commit e60d58a

3 files changed

Lines changed: 44 additions & 44 deletions

File tree

calling/callcontrol_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ func TestLine(t *testing.T) {
441441
t.Run("Register already registered is no-op", func(t *testing.T) {
442442
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
443443
w.WriteHeader(http.StatusOK)
444-
json.NewEncoder(w).Encode(MobiusDeviceInfo{
444+
_ = json.NewEncoder(w).Encode(MobiusDeviceInfo{
445445
Device: &DeviceType{DeviceID: "dev-1"},
446446
})
447447
}))
@@ -466,7 +466,7 @@ func TestLine(t *testing.T) {
466466
t.Run("GetDeviceInfo", func(t *testing.T) {
467467
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
468468
w.WriteHeader(http.StatusOK)
469-
json.NewEncoder(w).Encode(MobiusDeviceInfo{
469+
_ = json.NewEncoder(w).Encode(MobiusDeviceInfo{
470470
UserID: "user-xyz",
471471
Device: &DeviceType{DeviceID: "dev-1"},
472472
})
@@ -828,7 +828,7 @@ func TestCallingClient(t *testing.T) {
828828
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
829829
if r.Method == http.MethodPost {
830830
w.WriteHeader(http.StatusOK)
831-
json.NewEncoder(w).Encode(MobiusDeviceInfo{
831+
_ = json.NewEncoder(w).Encode(MobiusDeviceInfo{
832832
Device: &DeviceType{DeviceID: "dev-1"},
833833
})
834834
return

calling/calling_test.go

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func TestCallHistoryGetCallHistoryData(t *testing.T) {
9999
t.Errorf("Expected days=7, got %s", r.URL.Query().Get("days"))
100100
}
101101
w.WriteHeader(http.StatusOK)
102-
json.NewEncoder(w).Encode(map[string]interface{}{
102+
_ = json.NewEncoder(w).Encode(map[string]interface{}{
103103
"userSessions": []map[string]interface{}{
104104
{"id": "session-1", "sessionId": "s1", "disposition": "Answered", "direction": "outbound"},
105105
{"id": "session-2", "sessionId": "s2", "disposition": "MISSED", "direction": "inbound"},
@@ -129,7 +129,7 @@ func TestCallHistoryGetCallHistoryData(t *testing.T) {
129129
t.Run("error response", func(t *testing.T) {
130130
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
131131
w.WriteHeader(http.StatusUnauthorized)
132-
json.NewEncoder(w).Encode(map[string]string{"message": "Unauthorized"})
132+
_ = json.NewEncoder(w).Encode(map[string]string{"message": "Unauthorized"})
133133
}))
134134
defer server.Close()
135135

@@ -209,7 +209,7 @@ func TestCallSettingsGetCallWaiting(t *testing.T) {
209209
t.Errorf("Unexpected path: %s", r.URL.Path)
210210
}
211211
w.WriteHeader(http.StatusOK)
212-
json.NewEncoder(w).Encode(map[string]interface{}{
212+
_ = json.NewEncoder(w).Encode(map[string]interface{}{
213213
"enabled": true,
214214
"ringSplashEnabled": false,
215215
})
@@ -237,7 +237,7 @@ func TestCallSettingsGetDND(t *testing.T) {
237237
t.Errorf("Unexpected path: %s", r.URL.Path)
238238
}
239239
w.WriteHeader(http.StatusOK)
240-
json.NewEncoder(w).Encode(map[string]interface{}{"enabled": true})
240+
_ = json.NewEncoder(w).Encode(map[string]interface{}{"enabled": true})
241241
}))
242242
defer server.Close()
243243

@@ -288,7 +288,7 @@ func TestCallSettingsGetCallForward(t *testing.T) {
288288
t.Errorf("Unexpected path: %s", r.URL.Path)
289289
}
290290
w.WriteHeader(http.StatusOK)
291-
json.NewEncoder(w).Encode(map[string]interface{}{
291+
_ = json.NewEncoder(w).Encode(map[string]interface{}{
292292
"callForwarding": map[string]interface{}{
293293
"always": map[string]interface{}{"enabled": false},
294294
},
@@ -341,7 +341,7 @@ func TestCallSettingsGetVoicemail(t *testing.T) {
341341
t.Errorf("Unexpected path: %s", r.URL.Path)
342342
}
343343
w.WriteHeader(http.StatusOK)
344-
json.NewEncoder(w).Encode(map[string]interface{}{"enabled": true})
344+
_ = json.NewEncoder(w).Encode(map[string]interface{}{"enabled": true})
345345
}))
346346
defer server.Close()
347347

@@ -389,7 +389,7 @@ func TestCallSettingsGetCallForwardAlways(t *testing.T) {
389389
t.Error("Did not expect directoryNumber query param")
390390
}
391391
w.WriteHeader(http.StatusOK)
392-
json.NewEncoder(w).Encode(map[string]interface{}{"enabled": false})
392+
_ = json.NewEncoder(w).Encode(map[string]interface{}{"enabled": false})
393393
}))
394394
defer server.Close()
395395

@@ -411,7 +411,7 @@ func TestCallSettingsGetCallForwardAlways(t *testing.T) {
411411
t.Errorf("Expected directoryNumber=1234, got %s", r.URL.Query().Get("directoryNumber"))
412412
}
413413
w.WriteHeader(http.StatusOK)
414-
json.NewEncoder(w).Encode(map[string]interface{}{"enabled": true})
414+
_ = json.NewEncoder(w).Encode(map[string]interface{}{"enabled": true})
415415
}))
416416
defer server.Close()
417417

@@ -431,7 +431,7 @@ func TestCallSettingsGetCallForwardAlways(t *testing.T) {
431431
func TestCallSettingsErrorResponse(t *testing.T) {
432432
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
433433
w.WriteHeader(http.StatusForbidden)
434-
json.NewEncoder(w).Encode(map[string]string{"message": "Forbidden"})
434+
_ = json.NewEncoder(w).Encode(map[string]string{"message": "Forbidden"})
435435
}))
436436
defer server.Close()
437437

@@ -461,7 +461,7 @@ func TestVoicemailGetList(t *testing.T) {
461461
t.Errorf("Expected offset=0, got %s", r.URL.Query().Get("offset"))
462462
}
463463
w.WriteHeader(http.StatusOK)
464-
json.NewEncoder(w).Encode(map[string]interface{}{
464+
_ = json.NewEncoder(w).Encode(map[string]interface{}{
465465
"items": []map[string]interface{}{
466466
{"messageId": "msg-1", "duration": "30"},
467467
{"messageId": "msg-2", "duration": "45"},
@@ -491,7 +491,7 @@ func TestVoicemailGetContent(t *testing.T) {
491491
t.Errorf("Unexpected path: %s", r.URL.Path)
492492
}
493493
w.WriteHeader(http.StatusOK)
494-
json.NewEncoder(w).Encode(map[string]interface{}{
494+
_ = json.NewEncoder(w).Encode(map[string]interface{}{
495495
"type": "audio/wav",
496496
"content": "base64-encoded-audio",
497497
})
@@ -516,7 +516,7 @@ func TestVoicemailGetContent(t *testing.T) {
516516
func TestVoicemailGetSummary(t *testing.T) {
517517
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
518518
w.WriteHeader(http.StatusOK)
519-
json.NewEncoder(w).Encode(map[string]interface{}{
519+
_ = json.NewEncoder(w).Encode(map[string]interface{}{
520520
"newMessages": 3,
521521
"oldMessages": 10,
522522
"newUrgentMessages": 1,
@@ -618,7 +618,7 @@ func TestVoicemailGetTranscript(t *testing.T) {
618618
t.Errorf("Unexpected path: %s", r.URL.Path)
619619
}
620620
w.WriteHeader(http.StatusOK)
621-
json.NewEncoder(w).Encode(map[string]string{
621+
_ = json.NewEncoder(w).Encode(map[string]string{
622622
"transcript": "Hello, this is a test voicemail.",
623623
})
624624
}))
@@ -642,7 +642,7 @@ func TestVoicemailGetTranscript(t *testing.T) {
642642
func TestVoicemailErrorResponse(t *testing.T) {
643643
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
644644
w.WriteHeader(http.StatusServiceUnavailable)
645-
json.NewEncoder(w).Encode(map[string]string{"message": "Service unavailable"})
645+
_ = json.NewEncoder(w).Encode(map[string]string{"message": "Service unavailable"})
646646
}))
647647
defer server.Close()
648648

@@ -669,7 +669,7 @@ func TestContactsGetContacts(t *testing.T) {
669669
t.Errorf("Unexpected path: %s", r.URL.Path)
670670
}
671671
w.WriteHeader(http.StatusOK)
672-
json.NewEncoder(w).Encode(map[string]interface{}{
672+
_ = json.NewEncoder(w).Encode(map[string]interface{}{
673673
"contacts": []map[string]interface{}{
674674
{"contactId": "c1", "displayName": "Alice", "contactType": "CLOUD", "encryptionKeyUrl": "kms://key1", "groups": []string{}, "resolved": true},
675675
},
@@ -719,7 +719,7 @@ func TestContactsCreateContactGroup(t *testing.T) {
719719
}
720720

721721
w.WriteHeader(http.StatusCreated)
722-
json.NewEncoder(w).Encode(map[string]interface{}{
722+
_ = json.NewEncoder(w).Encode(map[string]interface{}{
723723
"group": map[string]interface{}{
724724
"groupId": "g-new",
725725
"displayName": "My Group",
@@ -775,7 +775,7 @@ func TestContactsCreateContact(t *testing.T) {
775775
t.Errorf("Expected POST, got %s", r.Method)
776776
}
777777
w.WriteHeader(http.StatusCreated)
778-
json.NewEncoder(w).Encode(map[string]interface{}{
778+
_ = json.NewEncoder(w).Encode(map[string]interface{}{
779779
"contact": map[string]interface{}{
780780
"contactId": "c-new",
781781
"displayName": "Bob",
@@ -836,7 +836,7 @@ func TestContactsDeleteContact(t *testing.T) {
836836
func TestContactsErrorResponse(t *testing.T) {
837837
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
838838
w.WriteHeader(http.StatusNotFound)
839-
json.NewEncoder(w).Encode(map[string]string{"message": "Not found"})
839+
_ = json.NewEncoder(w).Encode(map[string]string{"message": "Not found"})
840840
}))
841841
defer server.Close()
842842

contents/contents_test.go

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ func TestDownloadFromURL(t *testing.T) {
109109
w.Header().Set("Content-Type", "image/png")
110110
w.Header().Set("Content-Disposition", `attachment; filename="photo.png"`)
111111
w.WriteHeader(http.StatusOK)
112-
w.Write(imageData)
112+
_, _ = w.Write(imageData)
113113
}))
114114
defer server.Close()
115115

@@ -142,7 +142,7 @@ func TestDownload_StructuredErrors(t *testing.T) {
142142
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
143143
w.Header().Set("Content-Type", "application/json")
144144
w.WriteHeader(http.StatusNotFound)
145-
w.Write([]byte(`{"message":"content not found","trackingId":"test-123"}`))
145+
_, _ = w.Write([]byte(`{"message":"content not found","trackingId":"test-123"}`))
146146
}))
147147
defer server.Close()
148148

@@ -169,7 +169,7 @@ func TestDownload_410Gone_InfectedFile(t *testing.T) {
169169
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
170170
w.Header().Set("Content-Type", "application/json")
171171
w.WriteHeader(http.StatusGone)
172-
w.Write([]byte(`{"message":"file is infected and unavailable"}`))
172+
_, _ = w.Write([]byte(`{"message":"file is infected and unavailable"}`))
173173
}))
174174
defer server.Close()
175175

@@ -189,7 +189,7 @@ func TestDownload_428PreconditionRequired_UnscannableFile(t *testing.T) {
189189
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
190190
w.Header().Set("Content-Type", "application/json")
191191
w.WriteHeader(428)
192-
w.Write([]byte(`{"message":"file cannot be scanned"}`))
192+
_, _ = w.Write([]byte(`{"message":"file cannot be scanned"}`))
193193
}))
194194
defer server.Close()
195195

@@ -211,14 +211,14 @@ func TestDownloadWithOptions_AllowUnscannable(t *testing.T) {
211211
// Verify allow=unscannable query parameter
212212
if r.URL.Query().Get("allow") != "unscannable" {
213213
w.WriteHeader(428)
214-
w.Write([]byte(`{"message":"file cannot be scanned"}`))
214+
_, _ = w.Write([]byte(`{"message":"file cannot be scanned"}`))
215215
return
216216
}
217217

218218
w.Header().Set("Content-Type", "application/octet-stream")
219219
w.Header().Set("Content-Disposition", `attachment; filename="encrypted.zip"`)
220220
w.WriteHeader(http.StatusOK)
221-
w.Write(fileData)
221+
_, _ = w.Write(fileData)
222222
}))
223223
defer server.Close()
224224

@@ -246,7 +246,7 @@ func TestDownloadWithOptions_NilOptions(t *testing.T) {
246246
}
247247
w.Header().Set("Content-Type", "text/plain")
248248
w.WriteHeader(http.StatusOK)
249-
w.Write(fileData)
249+
_, _ = w.Write(fileData)
250250
}))
251251
defer server.Close()
252252

@@ -267,7 +267,7 @@ func TestDownloadWithOptions_FalseUnscannable(t *testing.T) {
267267
t.Error("Expected no allow query param when AllowUnscannable=false")
268268
}
269269
w.WriteHeader(http.StatusOK)
270-
w.Write([]byte("data"))
270+
_, _ = w.Write([]byte("data"))
271271
}))
272272
defer server.Close()
273273

@@ -284,7 +284,7 @@ func TestDownloadFromURL_StructuredErrors(t *testing.T) {
284284
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
285285
w.Header().Set("Content-Type", "application/json")
286286
w.WriteHeader(http.StatusForbidden)
287-
w.Write([]byte(`{"message":"access denied","trackingId":"track-456"}`))
287+
_, _ = w.Write([]byte(`{"message":"access denied","trackingId":"track-456"}`))
288288
}))
289289
defer server.Close()
290290

@@ -304,12 +304,12 @@ func TestDownloadFromURLWithOptions_AllowUnscannable(t *testing.T) {
304304
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
305305
if r.URL.Query().Get("allow") != "unscannable" {
306306
w.WriteHeader(428)
307-
w.Write([]byte(`{"message":"unscannable"}`))
307+
_, _ = w.Write([]byte(`{"message":"unscannable"}`))
308308
return
309309
}
310310
w.Header().Set("Content-Type", "application/octet-stream")
311311
w.WriteHeader(http.StatusOK)
312-
w.Write(fileData)
312+
_, _ = w.Write(fileData)
313313
}))
314314
defer server.Close()
315315

@@ -333,7 +333,7 @@ func TestDownload_423Locked_ReturnsLockedError(t *testing.T) {
333333
w.Header().Set("Content-Type", "application/json")
334334
w.Header().Set("Retry-After", "1")
335335
w.WriteHeader(423)
336-
w.Write([]byte(`{"message":"file is being scanned"}`))
336+
_, _ = w.Write([]byte(`{"message":"file is being scanned"}`))
337337
}))
338338
defer server.Close()
339339

@@ -392,13 +392,13 @@ func TestDownload_423AutoRetrySuccess(t *testing.T) {
392392
w.Header().Set("Content-Type", "application/json")
393393
w.Header().Set("Retry-After", "0")
394394
w.WriteHeader(423)
395-
w.Write([]byte(`{"message":"file is being scanned"}`))
395+
_, _ = w.Write([]byte(`{"message":"file is being scanned"}`))
396396
return
397397
}
398398
w.Header().Set("Content-Type", "text/plain")
399399
w.Header().Set("Content-Disposition", `attachment; filename="scanned.txt"`)
400400
w.WriteHeader(http.StatusOK)
401-
w.Write(fileData)
401+
_, _ = w.Write(fileData)
402402
}))
403403
defer server.Close()
404404

@@ -426,7 +426,7 @@ func TestDownload_423RetriesExhausted(t *testing.T) {
426426
w.Header().Set("Content-Type", "application/json")
427427
w.Header().Set("Retry-After", "0")
428428
w.WriteHeader(423)
429-
w.Write([]byte(`{"message":"file is being scanned"}`))
429+
_, _ = w.Write([]byte(`{"message":"file is being scanned"}`))
430430
}))
431431
defer server.Close()
432432

@@ -454,12 +454,12 @@ func TestDownload_423RetryWithRetryAfterHeader(t *testing.T) {
454454
w.Header().Set("Content-Type", "application/json")
455455
w.Header().Set("Retry-After", "1")
456456
w.WriteHeader(423)
457-
w.Write([]byte(`{"message":"scanning"}`))
457+
_, _ = w.Write([]byte(`{"message":"scanning"}`))
458458
return
459459
}
460460
w.Header().Set("Content-Type", "text/plain")
461461
w.WriteHeader(http.StatusOK)
462-
w.Write(fileData)
462+
_, _ = w.Write(fileData)
463463
}))
464464
defer server.Close()
465465

@@ -492,13 +492,13 @@ func TestDownloadFromURL_423AutoRetrySuccess(t *testing.T) {
492492
w.Header().Set("Content-Type", "application/json")
493493
w.Header().Set("Retry-After", "0")
494494
w.WriteHeader(423)
495-
w.Write([]byte(`{"message":"scanning"}`))
495+
_, _ = w.Write([]byte(`{"message":"scanning"}`))
496496
return
497497
}
498498
w.Header().Set("Content-Type", "image/png")
499499
w.Header().Set("Content-Disposition", `attachment; filename="photo.png"`)
500500
w.WriteHeader(http.StatusOK)
501-
w.Write(fileData)
501+
_, _ = w.Write(fileData)
502502
}))
503503
defer server.Close()
504504

@@ -527,7 +527,7 @@ func TestDownloadFromURLWithOptions_423AutoRetry(t *testing.T) {
527527
if attempts <= 2 {
528528
w.Header().Set("Retry-After", "0")
529529
w.WriteHeader(423)
530-
w.Write([]byte(`{"message":"scanning"}`))
530+
_, _ = w.Write([]byte(`{"message":"scanning"}`))
531531
return
532532
}
533533
// Verify allow=unscannable is still present on retry
@@ -536,7 +536,7 @@ func TestDownloadFromURLWithOptions_423AutoRetry(t *testing.T) {
536536
}
537537
w.Header().Set("Content-Type", "application/octet-stream")
538538
w.WriteHeader(http.StatusOK)
539-
w.Write(fileData)
539+
_, _ = w.Write(fileData)
540540
}))
541541
defer server.Close()
542542

@@ -563,12 +563,12 @@ func TestDownloadWithOptions_423AutoRetry(t *testing.T) {
563563
if attempts == 1 {
564564
w.Header().Set("Retry-After", "0")
565565
w.WriteHeader(423)
566-
w.Write([]byte(`{"message":"scanning"}`))
566+
_, _ = w.Write([]byte(`{"message":"scanning"}`))
567567
return
568568
}
569569
w.Header().Set("Content-Type", "application/pdf")
570570
w.WriteHeader(http.StatusOK)
571-
w.Write(fileData)
571+
_, _ = w.Write(fileData)
572572
}))
573573
defer server.Close()
574574

0 commit comments

Comments
 (0)