From b5302bdc8c84e0bd32534a08f9c3e772ee09c329 Mon Sep 17 00:00:00 2001 From: grumbulon Date: Sat, 11 Mar 2023 06:54:09 -0500 Subject: [PATCH] remove unused code and file. --- internal/api/api_test.go | 52 ++++----------------------------------- internal/logger/logger.go | 1 - 2 files changed, 5 insertions(+), 48 deletions(-) delete mode 100644 internal/logger/logger.go diff --git a/internal/api/api_test.go b/internal/api/api_test.go index 6f67767..ebee398 100644 --- a/internal/api/api_test.go +++ b/internal/api/api_test.go @@ -2,9 +2,7 @@ package api import ( "bytes" - "encoding/json" "fmt" - "io" "mime/multipart" "net/http" "net/http/httptest" @@ -24,12 +22,6 @@ import ( "gorm.io/gorm" ) -type response struct { - Username string `json:"username"` - Message string `json:"message"` - Status int `json:"status"` -} - type accountTest struct { username string password string @@ -52,7 +44,7 @@ func makeTestToken(username string) (tokenString string, err error) { func TestAPI(t *testing.T) { config, err := internal.ReadConfig() if err != nil { - panic(err) + assert.NotNil(t, err) } pomme := chi.NewRouter() @@ -204,8 +196,6 @@ func (a *accountTest) TestOpenRoutes(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - var target response - client := http.Client{} form := url.Values{} @@ -222,13 +212,6 @@ func (a *accountTest) TestOpenRoutes(t *testing.T) { assert.NotNil(t, err) } - respBody, _ := io.ReadAll(resp.Body) - - err = json.Unmarshal(respBody, &target) - if err != nil { - assert.NotNil(t, err) - } - assert.Equal(t, tc.expected.response, resp.StatusCode) } }) @@ -260,8 +243,6 @@ func (a *accountTest) TestRateLimit(t *testing.T) { } for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - var target response - client := http.Client{} form := url.Values{} @@ -275,12 +256,6 @@ func (a *accountTest) TestRateLimit(t *testing.T) { assert.NotNil(t, err) } - respBody, _ := io.ReadAll(resp.Body) - - err = json.Unmarshal(respBody, &target) - if err != nil { - assert.NotNil(t, err) - } if resp.StatusCode == tc.expected.response { assert.Equal(t, tc.expected.response, resp.StatusCode) } @@ -320,11 +295,10 @@ func (a *accountTest) TestProtectedRoutes(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { var ( - f *os.File - target response - err error - buf = new(bytes.Buffer) - w = multipart.NewWriter(buf) + f *os.File + err error + buf = new(bytes.Buffer) + w = multipart.NewWriter(buf) ) f, err = os.CreateTemp(".", "zonefile") @@ -373,13 +347,6 @@ func (a *accountTest) TestProtectedRoutes(t *testing.T) { if err != nil { assert.NotNil(t, err) } - - respBody, _ := io.ReadAll(resp.Body) - - err = json.Unmarshal(respBody, &target) - if err != nil { - assert.NotNil(t, err) - } assert.Equal(t, tc.expected.response, resp.StatusCode) } }) @@ -387,15 +354,6 @@ func (a *accountTest) TestProtectedRoutes(t *testing.T) { } func (a *accountTest) CleanUp(db *gorm.DB) { - var ( - user internal.User - req internal.ZoneRequest - ) - - db.Where("username = ?", a.username).Delete(&user) - - db.Where("user = ?", a.username).Delete(&req) - if err := os.Remove("pomme-test.sqlite"); err != nil { l := newResponder(Response[any]{ Message: "unable to clean up test DB", diff --git a/internal/logger/logger.go b/internal/logger/logger.go deleted file mode 100644 index 90c66f6..0000000 --- a/internal/logger/logger.go +++ /dev/null @@ -1 +0,0 @@ -package logger