Skip to content

Commit 0ca0e64

Browse files
committed
address review comments
Signed-off-by: Max Kotliar <[email protected]>
1 parent 368f6ff commit 0ca0e64

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

exp/api/remote/remote_api_test.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -303,25 +303,25 @@ func TestRemoteAPI_Write_WithHandler(t *testing.T) {
303303
func TestSnappyDecodeMiddleware(t *testing.T) {
304304
tLogger := slog.Default()
305305

306-
var actReq *writev2.Request
307-
successH := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
306+
var gotRequest *writev2.Request
307+
successHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
308308
b, err := io.ReadAll(r.Body)
309309
if err != nil {
310310
t.Fatalf("failed to read body: %v", err)
311311
}
312-
actReq = &writev2.Request{}
313-
if err := proto.Unmarshal(b, actReq); err != nil {
312+
gotRequest = &writev2.Request{}
313+
if err := proto.Unmarshal(b, gotRequest); err != nil {
314314
t.Fatalf("failed to unmarshal request: %v", err)
315315
}
316316

317317
w.WriteHeader(http.StatusOK)
318318
})
319319

320-
mw := SnappyDecodeMiddleware(tLogger)(successH)
320+
mw := SnappyDecodeMiddleware(tLogger)(successHandler)
321321

322322
t.Run("success", func(t *testing.T) {
323-
// populated by successH handler
324-
actReq = nil
323+
// populated by successHandler handler
324+
gotRequest = nil
325325
expReq := testV2()
326326

327327
serializedExpReq, err := proto.Marshal(expReq)
@@ -340,14 +340,14 @@ func TestSnappyDecodeMiddleware(t *testing.T) {
340340
if rw.Code != http.StatusOK {
341341
t.Fatalf("expected status 200, got %d: %s", rw.Code, rw.Body.String())
342342
}
343-
if diff := cmp.Diff(expReq, actReq, protocmp.Transform()); diff != "" {
343+
if diff := cmp.Diff(expReq, gotRequest, protocmp.Transform()); diff != "" {
344344
t.Fatalf("unexpected request after decoding: %s", diff)
345345
}
346346
})
347347

348348
t.Run("too_big", func(t *testing.T) {
349-
// populated by successH handler
350-
actReq = nil
349+
// populated by successHandler handler
350+
gotRequest = nil
351351

352352
s := writev2.NewSymbolTable()
353353
expReq := &writev2.Request{}
@@ -383,8 +383,8 @@ func TestSnappyDecodeMiddleware(t *testing.T) {
383383
}
384384

385385
body := rw.Body.String()
386-
if !strings.Contains(body, "decoded size exceeds maximum allowed") {
387-
t.Fatalf("expected error message about size limit, got: %s", body)
386+
if !strings.Contains(body, "decoded size exceeds the") {
387+
t.Fatalf("expected decoded size exceeds error, got: %s", body)
388388
}
389389
})
390390

@@ -407,8 +407,8 @@ func TestSnappyDecodeMiddleware(t *testing.T) {
407407
}
408408

409409
body := rw.Body.String()
410-
if !strings.Contains(body, "decoded size exceeds maximum allowed") {
411-
t.Fatalf("expected error message about size limit, got: %s", body)
410+
if !strings.Contains(body, "decoded size exceeds the") {
411+
t.Fatalf("expected decoded size exceeds error, got: %s", body)
412412
}
413413
})
414414

0 commit comments

Comments
 (0)