22 lines
466 B
Go
22 lines
466 B
Go
package handler
|
|
|
|
import (
|
|
"bytes"
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"testing"
|
|
)
|
|
|
|
func TestHabitFreezeHandler_Create_InvalidBody(t *testing.T) {
|
|
req := httptest.NewRequest("POST", "/habits/1/freeze", bytes.NewBufferString("bad"))
|
|
rr := httptest.NewRecorder()
|
|
|
|
h := &HabitFreezeHandler{freezeRepo: nil, habitRepo: nil}
|
|
h.Create(rr, req)
|
|
|
|
// No chi URL param → bad request
|
|
if rr.Code != http.StatusBadRequest {
|
|
t.Errorf("expected 400, got %d", rr.Code)
|
|
}
|
|
}
|