chore: 初始化仓库,导入项目基线代码
Academy v0.8.3 完整代码基线:Go 后端(internal/cmd/cli/mcp-server/docreader)、 Vue 前端(frontend)、数据库迁移(migrations)、部署编排(docker/helm/deploy)与文档。 今日开发的培训推送管理改动随后单独提交。
This commit is contained in:
commit
7ec21f35b0
5767 files changed
+1436788
No files matched your search
@@ -0,0 +1,41 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"academy/internal/types"
|
||||
"academy/internal/utils"
|
||||
)
|
||||
|
||||
func TestRequireTaskProgressTenant_RejectsCrossTenant(t *testing.T) {
|
||||
taskID := utils.GenerateTaskID("faq_import", 999, "kb-victim")
|
||||
ctx := context.WithValue(context.Background(), types.TenantIDContextKey, uint64(1))
|
||||
|
||||
err := requireTaskProgressTenant(ctx, taskID)
|
||||
if err == nil {
|
||||
t.Fatal("expected cross-tenant task to be rejected")
|
||||
}
|
||||
}
|
||||
|
||||
func TestRequireTaskProgressTenant_AllowsOwnTenant(t *testing.T) {
|
||||
taskID := utils.GenerateTaskID("kb_clone", 1, "kb-source")
|
||||
ctx := context.WithValue(context.Background(), types.TenantIDContextKey, uint64(1))
|
||||
|
||||
if err := requireTaskProgressTenant(ctx, taskID); err != nil {
|
||||
t.Fatalf("expected own-tenant task to pass, got %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRequireTaskProgressTenant_InvalidTaskID(t *testing.T) {
|
||||
ctx := context.WithValue(context.Background(), types.TenantIDContextKey, uint64(1))
|
||||
err := requireTaskProgressTenant(ctx, "not-a-task")
|
||||
if err == nil {
|
||||
t.Fatal("expected invalid task ID to fail")
|
||||
}
|
||||
if got := err.Error(); got == "" {
|
||||
t.Fatal("expected error message")
|
||||
}
|
||||
_ = http.StatusBadRequest
|
||||
}
|
||||
Reference in new issue
Block a user