[fix] Fixed tests scenarios
This commit is contained in:
parent
abfd08cc26
commit
10ecb6fd0d
@ -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)
|
||||
// }
|
||||
})
|
||||
}
|
||||
|
@ -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)
|
||||
// }
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user