[fix] Fixed tests scenarios

This commit is contained in:
Piotr Biernat 2022-03-14 16:25:17 +01:00
parent abfd08cc26
commit 10ecb6fd0d
2 changed files with 3 additions and 9 deletions

View File

@ -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)
// }
})
}

View File

@ -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)
// }
})
}