diff --git a/test/handler/create_article_test.go b/test/handler/create_article_test.go index 4394b4a..815a337 100644 --- a/test/handler/create_article_test.go +++ b/test/handler/create_article_test.go @@ -18,9 +18,5 @@ func TestCreateArticleHandler(t *testing.T) { if responseRecorder.Code != http.StatusCreated { t.Errorf("Want status '%d', got '%d'", http.StatusCreated, responseRecorder.Code) } - - // if strings.TrimSpace(responseRecorder.Body.String()) != tc.want { - // t.Errorf("Want '%s', got '%s'", tc.want, responseRecorder.Body) - // } }) } diff --git a/test/handler/create_category_test.go b/test/handler/create_category_test.go index 2270150..7c1be57 100644 --- a/test/handler/create_category_test.go +++ b/test/handler/create_category_test.go @@ -3,6 +3,7 @@ package main import ( "net/http" "net/http/httptest" + "strings" "testing" "git.pbiernat.dev/golang/rest-api-prototype/internal/app/handler" @@ -10,7 +11,8 @@ import ( func TestCreateCategoryHandler(t *testing.T) { t.Run("test create category handler", func(t *testing.T) { - request := httptest.NewRequest(http.MethodPost, "/api/category", nil) + body := "{\"name\":\"Test Category\"}" + request := httptest.NewRequest(http.MethodPost, "/api/category", strings.NewReader(body)) responseRecorder := httptest.NewRecorder() handler.CreateCategoryHandler.ServeHTTP(responseRecorder, request) @@ -18,9 +20,5 @@ func TestCreateCategoryHandler(t *testing.T) { if responseRecorder.Code != http.StatusCreated { t.Errorf("Want status '%d', got '%d'", http.StatusCreated, responseRecorder.Code) } - - // if strings.TrimSpace(responseRecorder.Body.String()) != tc.want { - // t.Errorf("Want '%s', got '%s'", tc.want, responseRecorder.Body) - // } }) }