You've already forked agentic-coding-workflow
bugfix
This commit is contained in:
@@ -32,7 +32,8 @@ func mountFullHandler(t *testing.T, ownerToken string, ownerID uuid.UUID) (*fake
|
||||
t.Helper()
|
||||
repo := newFakeRepo()
|
||||
pSvc := NewProjectService(repo, nil)
|
||||
rSvc := NewRequirementService(repo, nil)
|
||||
gate := NewGateRunner(GateDeps{Repo: repo, Workspace: nil}, nil)
|
||||
rSvc := NewRequirementService(repo, nil, nil, gate)
|
||||
iSvc := NewIssueService(repo, nil)
|
||||
artSvc := NewArtifactService(repo, nil)
|
||||
resolver := &fakeResolver{valid: map[string]uuid.UUID{ownerToken: ownerID}}
|
||||
@@ -235,9 +236,9 @@ func TestHandler_Artifacts_Routes(t *testing.T) {
|
||||
checkStatus(t, h, "POST", "/api/v1/projects/demo/requirements/1/artifacts", tok,
|
||||
map[string]any{"phase": "auditing", "content": "# audit"}, http.StatusCreated)
|
||||
|
||||
// 非法 phase → 400
|
||||
// 非法 phase(done 不在 ArtifactPhases)→ 400
|
||||
checkStatus(t, h, "POST", "/api/v1/projects/demo/requirements/1/artifacts", tok,
|
||||
map[string]any{"phase": "implementing", "content": "x"}, http.StatusBadRequest)
|
||||
map[string]any{"phase": "done", "content": "x"}, http.StatusBadRequest)
|
||||
|
||||
// list 裸数组:全量 2 条;?phase=planning 过滤 1 条
|
||||
respList := doJSON(t, h, "GET", "/api/v1/projects/demo/requirements/1/artifacts", tok, nil)
|
||||
@@ -265,3 +266,30 @@ func TestHandler_Artifacts_Routes(t *testing.T) {
|
||||
checkStatus(t, h, "GET", "/api/v1/projects/demo/requirements/1/artifacts/bogus/1", tok, nil, http.StatusBadRequest)
|
||||
checkStatus(t, h, "GET", "/api/v1/projects/demo/requirements/1/artifacts/planning/9", tok, nil, http.StatusNotFound)
|
||||
}
|
||||
|
||||
// TestHandler_ApproveArtifactAndGatedPhase 验证 approve 端点回写 verdict,且未满足
|
||||
// gate 的 phase 流转返回 409 phase_gate_failed,批准后放行 200。
|
||||
func TestHandler_ApproveArtifactAndGatedPhase(t *testing.T) {
|
||||
owner := uuid.New()
|
||||
tok := "tok"
|
||||
_, h := mountFullHandler(t, tok, owner)
|
||||
checkStatus(t, h, "POST", "/api/v1/projects/", tok, map[string]any{"slug": "demo", "name": "Demo"}, http.StatusCreated)
|
||||
checkStatus(t, h, "POST", "/api/v1/projects/demo/requirements", tok, map[string]any{"title": "R"}, http.StatusCreated)
|
||||
checkStatus(t, h, "POST", "/api/v1/projects/demo/requirements/1/artifacts", tok,
|
||||
map[string]any{"phase": "auditing", "content": "# audit"}, http.StatusCreated)
|
||||
|
||||
// 未批准 auditing 产物时流转到 implementing → 409 phase_gate_failed
|
||||
checkStatus(t, h, "POST", "/api/v1/projects/demo/requirements/1/phase", tok,
|
||||
map[string]any{"phase": "implementing"}, http.StatusConflict)
|
||||
|
||||
// approve 端点回写 verdict
|
||||
respApprove := doJSON(t, h, "POST", "/api/v1/projects/demo/requirements/1/artifacts/auditing/1/approve", tok,
|
||||
map[string]any{"verdict": "pass"})
|
||||
require.Equal(t, http.StatusOK, respApprove.StatusCode)
|
||||
approved := decodeBodyMap(t, respApprove)
|
||||
require.Equal(t, "pass", approved["verdict"])
|
||||
|
||||
// 批准后流转放行 → 200
|
||||
checkStatus(t, h, "POST", "/api/v1/projects/demo/requirements/1/phase", tok,
|
||||
map[string]any{"phase": "implementing"}, http.StatusOK)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user