]> git.giacomolli.uk - onechat/blobdiff - telegram_api_test.go
Correct the remaining review style findings
[onechat] / telegram_api_test.go
index 03d6c63b6b7691e04146c694e676e8c9a3b0ec15..0da139590f312a1014863ce98a9411ed6806495e 100644 (file)
@@ -150,7 +150,9 @@ func TestBotErrorsDoNotHoldTheToken(t *testing.T) {
                        reply: func(w http.ResponseWriter) {
                                conn, _, err := http.NewResponseController(w).Hijack()
                                if err == nil {
                        reply: func(w http.ResponseWriter) {
                                conn, _, err := http.NewResponseController(w).Hijack()
                                if err == nil {
-                                       _ = conn.Close()
+                                       // This forced disconnect has no
+                                       // response or retry after close.
+                                       conn.Close() // nolint: errcheck
                                }
                        },
                        retry:     true,
                                }
                        },
                        retry:     true,
@@ -161,7 +163,10 @@ func TestBotErrorsDoNotHoldTheToken(t *testing.T) {
                        reply: func(w http.ResponseWriter) {
                                w.WriteHeader(http.StatusTooManyRequests)
 
                        reply: func(w http.ResponseWriter) {
                                w.WriteHeader(http.StatusTooManyRequests)
 
-                               _, _ = io.WriteString(w, `{"ok":false,"error_code":429,"description":"Too Many Requests: retry after 3","parameters":{"retry_after":3}}`)
+                               _, err := io.WriteString(w, `{"ok":false,"error_code":429,"description":"Too Many Requests: retry after 3","parameters":{"retry_after":3}}`)
+                               if err != nil {
+                                       panic(err)
+                               }
                        },
                        retry:     true,
                        wait:      3 * time.Second,
                        },
                        retry:     true,
                        wait:      3 * time.Second,
@@ -172,7 +177,10 @@ func TestBotErrorsDoNotHoldTheToken(t *testing.T) {
                        reply: func(w http.ResponseWriter) {
                                w.WriteHeader(http.StatusBadGateway)
 
                        reply: func(w http.ResponseWriter) {
                                w.WriteHeader(http.StatusBadGateway)
 
-                               _, _ = io.WriteString(w, "<html>bad gateway</html>")
+                               _, err := io.WriteString(w, "<html>bad gateway</html>")
+                               if err != nil {
+                                       panic(err)
+                               }
                        },
                        retry:     true,
                        errorText: "502 Bad Gateway",
                        },
                        retry:     true,
                        errorText: "502 Bad Gateway",
@@ -182,7 +190,10 @@ func TestBotErrorsDoNotHoldTheToken(t *testing.T) {
                        reply: func(w http.ResponseWriter) {
                                w.WriteHeader(http.StatusUnauthorized)
 
                        reply: func(w http.ResponseWriter) {
                                w.WriteHeader(http.StatusUnauthorized)
 
-                               _, _ = io.WriteString(w, `{"ok":false,"error_code":401,"description":"Unauthorized: bot`+telegramTestToken+`"}`)
+                               _, err := io.WriteString(w, `{"ok":false,"error_code":401,"description":"Unauthorized: bot`+telegramTestToken+`"}`)
+                               if err != nil {
+                                       panic(err)
+                               }
                        },
                        retry:     false,
                        errorText: "Unauthorized: botTOKEN",
                        },
                        retry:     false,
                        errorText: "Unauthorized: botTOKEN",
@@ -192,7 +203,10 @@ func TestBotErrorsDoNotHoldTheToken(t *testing.T) {
                        reply: func(w http.ResponseWriter) {
                                w.WriteHeader(http.StatusBadRequest)
 
                        reply: func(w http.ResponseWriter) {
                                w.WriteHeader(http.StatusBadRequest)
 
-                               _, _ = io.WriteString(w, `{"ok":false,"error_code":400,"description":"Bad Request: can't parse"}`)
+                               _, err := io.WriteString(w, `{"ok":false,"error_code":400,"description":"Bad Request: can't parse"}`)
+                               if err != nil {
+                                       panic(err)
+                               }
                        },
                        retry:     false,
                        rejected:  true,
                        },
                        retry:     false,
                        rejected:  true,
@@ -203,7 +217,10 @@ func TestBotErrorsDoNotHoldTheToken(t *testing.T) {
                        reply: func(w http.ResponseWriter) {
                                w.WriteHeader(http.StatusNotFound)
 
                        reply: func(w http.ResponseWriter) {
                                w.WriteHeader(http.StatusNotFound)
 
-                               _, _ = io.WriteString(w, `{"ok":false,"error_code":404,"description":"Not Found"}`)
+                               _, err := io.WriteString(w, `{"ok":false,"error_code":404,"description":"Not Found"}`)
+                               if err != nil {
+                                       panic(err)
+                               }
                        },
                        retry:     false,
                        rejected:  true,
                        },
                        retry:     false,
                        rejected:  true,
@@ -214,7 +231,10 @@ func TestBotErrorsDoNotHoldTheToken(t *testing.T) {
                        reply: func(w http.ResponseWriter) {
                                w.WriteHeader(http.StatusNotFound)
 
                        reply: func(w http.ResponseWriter) {
                                w.WriteHeader(http.StatusNotFound)
 
-                               _, _ = io.WriteString(w, "<html>not found</html>")
+                               _, err := io.WriteString(w, "<html>not found</html>")
+                               if err != nil {
+                                       panic(err)
+                               }
                        },
                        retry:     false,
                        errorText: "404 Not Found",
                        },
                        retry:     false,
                        errorText: "404 Not Found",
@@ -222,7 +242,10 @@ func TestBotErrorsDoNotHoldTheToken(t *testing.T) {
                {
                        name: "broken answer is retried",
                        reply: func(w http.ResponseWriter) {
                {
                        name: "broken answer is retried",
                        reply: func(w http.ResponseWriter) {
-                               _, _ = io.WriteString(w, `{"ok":`)
+                               _, err := io.WriteString(w, `{"ok":`)
+                               if err != nil {
+                                       panic(err)
+                               }
                        },
                        retry:     true,
                        errorText: "invalid JSON",
                        },
                        retry:     true,
                        errorText: "invalid JSON",