forked from Gitlink/gitlink-cli
fix(shortcuts): 修复 milestone +close 路径并补回归测试
close 命令 API URL 误拼为 {repo_path}/{owner}/milestones/{id}/update_status(Owner 重复、Repo 丢失、缺 /v1),修正为 /v1/{owner}/{repo}/milestones/{id}/update_status;新增 TestMilestoneClose 回归测试。
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
af7b5aeea3
commit
fa69e6b862
|
|
@ -114,7 +114,7 @@ func Shortcuts() []*common.Shortcut {
|
|||
body := map[string]interface{}{
|
||||
"status": "closed",
|
||||
}
|
||||
env, err := ctx.CallAPI("POST", fmt.Sprintf("%s/%s/milestones/%s/update_status", ctx.RepoPath(), ctx.Owner, id), body)
|
||||
env, err := ctx.CallAPI("POST", fmt.Sprintf("%s/milestones/%s/update_status", v1Path(ctx), id), body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -115,3 +115,30 @@ func TestMilestoneDelete(t *testing.T) {
|
|||
t.Fatalf("delete failed: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMilestoneClose(t *testing.T) {
|
||||
var closePayload map[string]interface{}
|
||||
server := common.NewTestServer(t, func(w http.ResponseWriter, r *http.Request) {
|
||||
// Regression guard: +close must hit /v1/{owner}/{repo}/milestones/{id}/update_status
|
||||
// (previously malformed to /{owner}/{repo}/{owner}/milestones/{id}/update_status — Owner duplicated, Repo dropped, no /v1).
|
||||
if r.Method == "POST" && r.URL.Path == "/v1/owner/repo/milestones/1/update_status.json" {
|
||||
closePayload = common.DecodeJSON(t, r)
|
||||
common.WriteJSON(t, w, map[string]interface{}{
|
||||
"status": 0,
|
||||
"message": "更新成功",
|
||||
})
|
||||
} else {
|
||||
t.Fatalf("unexpected request: %s %s", r.Method, r.URL.Path)
|
||||
}
|
||||
})
|
||||
defer server.Close()
|
||||
|
||||
ctx := common.NewTestContext(t, server, "owner", "repo", map[string]string{
|
||||
"id": "1",
|
||||
})
|
||||
err := common.RunShortcut(t, Shortcuts(), "close", ctx)
|
||||
if err != nil {
|
||||
t.Fatalf("close failed: %v", err)
|
||||
}
|
||||
common.AssertEqual(t, closePayload["status"], "closed")
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue