feat(httpapi): websocket, router, embed static, main entrypoint
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user