- 新增 /api/auth/register、/api/auth/login,JWT 签发与 Bearer 鉴权中间件 - notes 需登录,users/user-groups 仅管理员;auth 配置项随版本 1→2 自动补全 - internal/api 仅保留路由装配,拆分为 auth/user/usergroup/note/httpx/testutil - 同步更新 Swagger 文档与前端注册接口路径
27 lines
577 B
Go
27 lines
577 B
Go
package api_test
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
"testing"
|
|
|
|
"rill/internal/testutil"
|
|
)
|
|
|
|
func TestHealth(t *testing.T) {
|
|
env := testutil.Setup(t)
|
|
|
|
w := testutil.Call(t, env.Router(""), http.MethodGet, "/api/health", nil)
|
|
if w.Code != http.StatusOK {
|
|
t.Fatalf("状态码 = %d, 期望 %d, body=%s", w.Code, http.StatusOK, w.Body.String())
|
|
}
|
|
|
|
var resp map[string]string
|
|
if err := json.Unmarshal(w.Body.Bytes(), &resp); err != nil {
|
|
t.Fatalf("解析响应失败: %v", err)
|
|
}
|
|
if resp["status"] != "ok" {
|
|
t.Errorf("status = %q, 期望 ok", resp["status"])
|
|
}
|
|
}
|