package handler import ( "bytes" "net/http" "net/http/httptest" "testing" ) func TestTaskHandler_Create_InvalidBody(t *testing.T) { req := httptest.NewRequest("POST", "/tasks", bytes.NewBufferString("not json")) rr := httptest.NewRecorder() h := &TaskHandler{taskService: nil} h.Create(rr, req) if rr.Code != http.StatusBadRequest { t.Errorf("expected 400, got %d", rr.Code) } } func TestTaskHandler_Create_EmptyTitle(t *testing.T) { body := `{"title":""}` req := httptest.NewRequest("POST", "/tasks", bytes.NewBufferString(body)) rr := httptest.NewRecorder() h := &TaskHandler{taskService: nil} h.Create(rr, req) if rr.Code != http.StatusBadRequest { t.Errorf("expected 400, got %d", rr.Code) } }