From adea95972d5eca55358b63971de9d03a5a8ef746 Mon Sep 17 00:00:00 2001 From: Matthew Rich Date: Wed, 10 Apr 2024 13:27:34 -0700 Subject: [PATCH] fix lint errors --- internal/resource/http.go | 6 +++--- internal/resource/http_test.go | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/internal/resource/http.go b/internal/resource/http.go index 8870f1b..cefb599 100644 --- a/internal/resource/http.go +++ b/internal/resource/http.go @@ -29,14 +29,14 @@ func HTTPFactory(u *url.URL) Resource { type HTTPHeader struct { Name string `yaml:"name" json:"name"` - Value string `yaml:"value" json"value"` + Value string `yaml:"value" json:"value"` } // Manage the state of an HTTP endpoint type HTTP struct { client *http.Client `yaml:"-" json:"-"` Endpoint string `yaml:"endpoint" json:"endpoint"` - Headers []HTTPHeader `yaml:"headers,omitempty", json:"headers,omitempty"` + Headers []HTTPHeader `yaml:"headers,omitempty" json:"headers,omitempty"` Body string `yaml:"body,omitempty" json:"body,omitempty"` State string `yaml:"state" json:"state"` } @@ -107,10 +107,10 @@ func (h *HTTP) Create() error { req.Header.Add(header.Name, header.Value) } resp, err := h.client.Do(req) - defer resp.Body.Close() if err != nil { return err } + defer resp.Body.Close() return err } diff --git a/internal/resource/http_test.go b/internal/resource/http_test.go index a555393..c9f8577 100644 --- a/internal/resource/http_test.go +++ b/internal/resource/http_test.go @@ -44,12 +44,14 @@ func TestHTTPRead(t *testing.T) { server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) { assert.Equal(t, req.URL.String(), "/resource/user/foo") - rw.Write([]byte(` + n,e := rw.Write([]byte(` type: "user" attributes: name: "foo" gecos: "foo user" `)) + assert.Nil(t, e) + assert.Greater(t, n, 0) })) defer server.Close()