Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Internal] fixing lint issues #15162

Merged
8 commits merged into from
Jul 28, 2021
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion sdk/internal/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ trigger:
paths:
include:
- sdk/internal/
- eng/
catalinaperalta marked this conversation as resolved.
Show resolved Hide resolved

pr:
paths:
include:
- sdk/internal/

- eng/

stages:
- template: ../../eng/pipelines/templates/jobs/archetype-sdk-client.yml
parameters:
Expand Down
13 changes: 10 additions & 3 deletions sdk/internal/mock/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,10 @@ func (s *Server) serveHTTP(w http.ResponseWriter, req *http.Request) {
if resp.delay > 0 {
time.Sleep(resp.delay)
}
resp.write(w)
err := resp.write(w)
if err != nil {
panic(err)
}
}

// Requests returns the number of times an HTTP request was made.
Expand Down Expand Up @@ -259,7 +262,7 @@ type mockResponse struct {
pred ResponsePredicate
}

func (mr mockResponse) write(w http.ResponseWriter) {
func (mr mockResponse) write(w http.ResponseWriter) error {
if len(mr.headers) > 0 {
for k, v := range mr.headers {
for _, vv := range v {
Expand All @@ -272,8 +275,12 @@ func (mr mockResponse) write(w http.ResponseWriter) {
}
w.WriteHeader(mr.code)
if mr.body != nil {
w.Write(mr.body)
_, err := w.Write(mr.body)
if err != nil {
return err
}
}
return nil
}

// WithStatusCode sets the HTTP response's status code to the specified value.
Expand Down
1 change: 0 additions & 1 deletion sdk/internal/mock/mock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,6 @@ func TestTLSServerConfig(t *testing.T) {
func TestBodyReadError(t *testing.T) {
srv, close := NewServer()
defer close()
const body = "this is the response body"
srv.AppendResponse(WithBodyReadError())
req, err := http.NewRequest(http.MethodGet, srv.URL(), nil)
if err != nil {
Expand Down
8 changes: 7 additions & 1 deletion sdk/internal/recording/recording.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,10 @@ func (r *Recording) Do(req *http.Request) (*http.Response, error) {
// Stop stops the recording and saves them, including any captured variables, to disk
func (r *Recording) Stop() error {

r.recorder.Stop()
err := r.recorder.Stop()
if err != nil {
return err
}
if r.Mode == Live {
return nil
}
Expand Down Expand Up @@ -405,6 +408,9 @@ func (r *Recording) unmarshalVariablesFile(out interface{}) error {
}
} else {
err = yaml.Unmarshal(data, out)
if err != nil {
return err
}
}
return nil
}
Expand Down
Loading