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 (
"net/http"
"net/http/httptest"
"testing"
)
func TestInterestHandler_CalculateInterest_Unauthorized(t *testing.T) {
h := &InterestHandler{
service: nil,
secretKey: "test-secret",
}
// No header
req := httptest.NewRequest("POST", "/internal/calculate-interest", nil)
rr := httptest.NewRecorder()
h.CalculateInterest(rr, req)
if rr.Code != http.StatusUnauthorized {
t.Errorf("expected 401, got %d", rr.Code)
}
// Wrong header
req2 := httptest.NewRequest("POST", "/internal/calculate-interest", nil)
req2.Header.Set("X-Internal-Key", "wrong-key")
rr2 := httptest.NewRecorder()
h.CalculateInterest(rr2, req2)
if rr2.Code != http.StatusUnauthorized {
t.Errorf("expected 401, got %d", rr2.Code)
}
}