feat(backend): module scaffold, config, gin router with healthz

This commit is contained in:
2026-09-04 23:39:31 +08:00
parent 2458c9ca4d
commit ad934d9812
5 changed files with 238 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
package api
import (
"net/http"
"net/http/httptest"
"testing"
"time"
"booklib/internal/config"
)
func testCfg() *config.Config {
return &config.Config{Addr: ":8080", JWTSecret: []byte("s3cret"), ScanInterval: time.Minute, UploadMaxMB: 200}
}
func TestHealthz(t *testing.T) {
r := NewRouter(testCfg())
req := httptest.NewRequest(http.MethodGet, "/api/healthz", nil)
w := httptest.NewRecorder()
r.ServeHTTP(w, req)
if w.Code != http.StatusOK {
t.Fatalf("healthz = %d, want 200", w.Code)
}
}