Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
phughes-scwx committed Nov 27, 2024
1 parent 27ac53d commit e46a835
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
11 changes: 7 additions & 4 deletions client/incremental_http.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package client
import (
"context"
"encoding/json"
"errors"
"fmt"
"io"
"mime"
Expand Down Expand Up @@ -93,7 +94,7 @@ func (p *Client) IncrementalHTTP(ctx context.Context, query string, options ...O
w := httptest.NewRecorder()
p.h.ServeHTTP(w, r)

res := w.Result()
res := w.Result() //nolint:bodyclose // Remains open since we are reading from it incrementally.
if res.StatusCode >= http.StatusBadRequest {
return errorIncremental(fmt.Errorf("http %d: %s", w.Code, w.Body.String()))
}
Expand All @@ -110,12 +111,12 @@ func (p *Client) IncrementalHTTP(ctx context.Context, query string, options ...O
// expected range.
deferSpec, ok := params["deferspec"]
if !ok || deferSpec == "" {
return errorIncremental(fmt.Errorf("expected deferSpec in content-type"))
return errorIncremental(errors.New("expected deferSpec in content-type"))
}

boundary, ok := params["boundary"]
if !ok || boundary == "" {
return errorIncremental(fmt.Errorf("expected boundary in content-type"))
return errorIncremental(errors.New("expected boundary in content-type"))
}
mr := multipart.NewReader(res.Body, boundary)

Expand All @@ -130,6 +131,7 @@ func (p *Client) IncrementalHTTP(ctx context.Context, query string, options ...O
next: func(response any) (err error) {
defer func() {
if err != nil {
res.Body.Close()
cancel(err)
}
}()
Expand Down Expand Up @@ -157,6 +159,7 @@ func (p *Client) IncrementalHTTP(ctx context.Context, query string, options ...O
}

if next.Err == io.EOF {
res.Body.Close()
cancel(context.Canceled)
return nil
}
Expand All @@ -181,7 +184,7 @@ func (p *Client) IncrementalHTTP(ctx context.Context, query string, options ...O
// We want to unpack even if there is an error, so we can see partial
// responses.
err = unpack(data, response, p.dc)
if rawErrors != nil {
if len(rawErrors) != 0 {
err = RawJsonError{rawErrors}
return err
}
Expand Down
16 changes: 8 additions & 8 deletions codegen/testserver/singlefile/defer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func TestDefer(t *testing.T) {
cases := []struct {
name string
query string
expectedInitialResponse interface{}
expectedInitialResponse any
expectedDeferredResponses []deferredData
}{
{
Expand Down Expand Up @@ -491,14 +491,14 @@ fragment DeferFragment on DeferModel {
if !valueResp.HasNext {
deferredResponses = append(deferredResponses, valueResp)
break
} else {
// Remove HasNext from comparison: we don't know the order they will be
// delivered in, and so this can't be known in the setup. But if HasNext
// does not work right we will either error out or get too few
// responses, so it's still checked.
valueResp.HasNext = false
deferredResponses = append(deferredResponses, valueResp)
}

// Remove HasNext from comparison: we don't know the order they will be
// delivered in, and so this can't be known in the setup. But if HasNext
// does not work right we will either error out or get too few
// responses, so it's still checked.
valueResp.HasNext = false
deferredResponses = append(deferredResponses, valueResp)
}
require.NoError(t, read.Close())

Expand Down

0 comments on commit e46a835

Please sign in to comment.