fix(pr_merge): advertise canonical number, demote index to alias (#45)
pr_merge was the only tool still advertising `index` as its id field while every other issue/PR tool uses the canonical `number` (#38). Flipped its schema property + required + struct field/tag `index` -> `number`; the existing `index`->`number` shim keeps legacy `index` callers working, so no shim change was needed (no canonical-`index` tool remains). Now the id arg is `number` uniformly across all per-issue/PR tools. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -63,6 +63,30 @@ func TestPRMergeConflictReturnsError(t *testing.T) {
|
||||
assert.ErrorIs(t, err, gitea.ErrConflict)
|
||||
}
|
||||
|
||||
// #45: pr_merge advertises the canonical `number` (was `index`); `index` stays
|
||||
// an accepted alias via the shim.
|
||||
func TestPRMergeNumberCanonical(t *testing.T) {
|
||||
sch := string(tools.NewPRMerge(gitea.NewClient("http://unused", ""), allowlist.New([]string{"owner"})).Descriptor().InputSchema)
|
||||
assert.Contains(t, sch, `"number":`, "pr_merge must advertise number")
|
||||
assert.NotContains(t, sch, `"index":`, "pr_merge must not advertise index")
|
||||
|
||||
for _, args := range []string{
|
||||
`{"owner":"owner","repo":"repo","number":7}`,
|
||||
`{"owner":"owner","repo":"repo","index":7}`,
|
||||
} {
|
||||
var gotPath string
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
gotPath = r.URL.Path
|
||||
w.WriteHeader(http.StatusNoContent)
|
||||
}))
|
||||
tool := tools.NewPRMerge(gitea.NewClient(srv.URL, "tok"), allowlist.New([]string{"owner"}))
|
||||
_, err := tool.Call(context.Background(), json.RawMessage(args))
|
||||
require.NoError(t, err, args)
|
||||
assert.Equal(t, "/api/v1/repos/owner/repo/pulls/7/merge", gotPath, args)
|
||||
srv.Close()
|
||||
}
|
||||
}
|
||||
|
||||
func TestPRMergeAllowlistRejects(t *testing.T) {
|
||||
tool := tools.NewPRMerge(gitea.NewClient("http://unused", ""), allowlist.New([]string{"allowed"}))
|
||||
_, err := tool.Call(context.Background(), json.RawMessage(`{"owner":"evil","name":"repo","index":1}`))
|
||||
|
||||
Reference in New Issue
Block a user