test: add handler and config tests (auth, tasks, habits, savings, profile, interest, freeze)
Some checks failed
CI / lint-test (push) Failing after 1s

This commit is contained in:
Cosmo
2026-03-26 19:03:12 +00:00
parent 999f9911a9
commit 3c8dd575c3
9 changed files with 2509 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
package handler
import (
"bytes"
"net/http"
"net/http/httptest"
"testing"
)
func TestHabitHandler_Create_InvalidBody(t *testing.T) {
req := httptest.NewRequest("POST", "/habits", bytes.NewBufferString("not json"))
rr := httptest.NewRecorder()
h := &HabitHandler{habitService: nil}
h.Create(rr, req)
if rr.Code != http.StatusBadRequest {
t.Errorf("expected 400, got %d", rr.Code)
}
}
func TestHabitHandler_Create_EmptyName(t *testing.T) {
body := `{"name":""}`
req := httptest.NewRequest("POST", "/habits", bytes.NewBufferString(body))
rr := httptest.NewRecorder()
h := &HabitHandler{habitService: nil}
h.Create(rr, req)
if rr.Code != http.StatusBadRequest {
t.Errorf("expected 400, got %d", rr.Code)
}
}