mirror of
https://gitea.com/gitea/tea.git
synced 2026-10-05 21:38:13 +02:00
feat(pulls): support branch-validated stack reordering
Assisted-by: Codet:GPT-5-Codex
This commit is contained in:
@@ -134,6 +134,24 @@ func TestAddPullStackEntry(t *testing.T) {
|
||||
assert.Equal(t, int64(5), stack.ID)
|
||||
}
|
||||
|
||||
func TestReorderPullStack(t *testing.T) {
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
assert.Equal(t, http.MethodPost, r.Method)
|
||||
assert.Equal(t, "/api/v1/repos/owner/repo/stacks/5/reorder", r.URL.Path)
|
||||
body, err := io.ReadAll(r.Body)
|
||||
require.NoError(t, err)
|
||||
assert.JSONEq(t, `{"pull_indices":[2,3]}`, string(body))
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
_, _ = w.Write([]byte(`{"id":5,"repo_id":2,"owner_id":3,"title":"feat: base","base_branch":"main","state":"open","auto_restack":true,"entries":[]}`))
|
||||
}))
|
||||
defer server.Close()
|
||||
result, err := ReorderPullStack(t.Context(), &config.Login{
|
||||
Name: "test", URL: server.URL, Token: "secret-token",
|
||||
}, "owner", "repo", 5, []int64{2, 3})
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, int64(5), result.ID)
|
||||
}
|
||||
|
||||
func TestRestackPullStack(t *testing.T) {
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
assert.Equal(t, http.MethodPost, r.Method)
|
||||
|
||||
Reference in New Issue
Block a user