feat(httpapi): websocket, router, embed static, main entrypoint

This commit is contained in:
2026-07-01 18:37:48 +07:00
parent 0bd4ba37e3
commit 9ec6acd414
8 changed files with 269 additions and 16 deletions
+27
View File
@@ -0,0 +1,27 @@
package httpapi
import (
"net/http"
"net/http/httptest"
"testing"
"github.com/vasyansk/imap-copier/internal/config"
)
func TestHealthzOpen(t *testing.T) {
s := &Server{cfg: config.Config{SessionSecret: []byte("x")}}
rw := httptest.NewRecorder()
s.Router().ServeHTTP(rw, httptest.NewRequest("GET", "/healthz", nil))
if rw.Code != http.StatusOK {
t.Fatalf("healthz=%d", rw.Code)
}
}
func TestTasksRequiresAuth(t *testing.T) {
s := &Server{cfg: config.Config{SessionSecret: []byte("x")}}
rw := httptest.NewRecorder()
s.Router().ServeHTTP(rw, httptest.NewRequest("GET", "/api/tasks", nil))
if rw.Code != http.StatusUnauthorized {
t.Fatalf("want 401, got %d", rw.Code)
}
}