Skip to content

Commit 80a73e7

Browse files
committed
Handle some unhandled errors in the tests
Signed-off-by: Richard Wall <[email protected]>
1 parent b344e46 commit 80a73e7

File tree

1 file changed

+16
-4
lines changed
  • pkg/internal/cyberark/dataupload

1 file changed

+16
-4
lines changed

pkg/internal/cyberark/dataupload/mock.go

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ func (mds *mockDataUploadServer) ServeHTTP(w http.ResponseWriter, r *http.Reques
5151
func (mds *mockDataUploadServer) handlePresignedUpload(w http.ResponseWriter, r *http.Request) {
5252
if r.Method != http.MethodPost {
5353
w.WriteHeader(http.StatusMethodNotAllowed)
54-
_, _ = w.Write([]byte(`{"message":"method not allowed"}`))
54+
_, err := w.Write([]byte(`{"message":"method not allowed"}`))
55+
if err != nil {
56+
panic(err)
57+
}
5558
return
5659
}
5760

@@ -95,7 +98,10 @@ func (mds *mockDataUploadServer) handlePresignedUpload(w http.ResponseWriter, r
9598
if req.ClusterID == "invalid-json-retrieve-presigned" {
9699
w.WriteHeader(http.StatusOK)
97100
w.Header().Set("Content-Type", "application/json")
98-
_, _ = w.Write([]byte(`{"url":`)) // invalid JSON
101+
_, err := w.Write([]byte(`{"url":`)) // invalid JSON
102+
if err != nil {
103+
panic(err)
104+
}
99105
return
100106
}
101107

@@ -122,7 +128,10 @@ func (mds *mockDataUploadServer) handlePresignedUpload(w http.ResponseWriter, r
122128
func (mds *mockDataUploadServer) handleUpload(w http.ResponseWriter, r *http.Request) {
123129
if r.Method != http.MethodPut {
124130
w.WriteHeader(http.StatusMethodNotAllowed)
125-
_, _ = w.Write([]byte(`{"message":"method not allowed"}`))
131+
_, err := w.Write([]byte(`{"message":"method not allowed"}`))
132+
if err != nil {
133+
panic(err)
134+
}
126135
return
127136
}
128137

@@ -132,7 +141,10 @@ func (mds *mockDataUploadServer) handleUpload(w http.ResponseWriter, r *http.Req
132141
}
133142

134143
checksum := sha256.New()
135-
_, _ = io.Copy(checksum, r.Body)
144+
_, err := io.Copy(checksum, r.Body)
145+
if err != nil {
146+
panic(err)
147+
}
136148

137149
if r.URL.Query().Get("checksum") != hex.EncodeToString(checksum.Sum(nil)) {
138150
http.Error(w, "checksum is invalid", http.StatusInternalServerError)

0 commit comments

Comments
 (0)