diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2024-12-12 16:10:09 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-12 08:10:09 +0000 |
commit | 22bf2ca6ba1b89bcb88217541f31900dd606391e (patch) | |
tree | 7e2e1d97ccc0eb44e6c8fb16244f2ba1ef317e00 /tests/integration/api_repo_compare_test.go | |
parent | 01b1896bf5eacfd7f4f64d9ebb0ad165e3e60a5c (diff) | |
download | gitea-22bf2ca6ba1b89bcb88217541f31900dd606391e.tar.gz gitea-22bf2ca6ba1b89bcb88217541f31900dd606391e.zip |
Make API "compare" accept commit IDs (#32801)
Diffstat (limited to 'tests/integration/api_repo_compare_test.go')
-rw-r--r-- | tests/integration/api_repo_compare_test.go | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/tests/integration/api_repo_compare_test.go b/tests/integration/api_repo_compare_test.go index f3188eb49f..9565e4d209 100644 --- a/tests/integration/api_repo_compare_test.go +++ b/tests/integration/api_repo_compare_test.go @@ -24,15 +24,27 @@ func TestAPICompareBranches(t *testing.T) { session := loginUser(t, user.Name) token := getTokenForLoggedInUser(t, session, auth_model.AccessTokenScopeWriteRepository) - repoName := "repo20" + t.Run("CompareBranches", func(t *testing.T) { + defer tests.PrintCurrentTest(t)() + req := NewRequestf(t, "GET", "/api/v1/repos/user2/repo20/compare/add-csv...remove-files-b").AddTokenAuth(token) + resp := MakeRequest(t, req, http.StatusOK) - req := NewRequestf(t, "GET", "/api/v1/repos/user2/%s/compare/add-csv...remove-files-b", repoName). - AddTokenAuth(token) - resp := MakeRequest(t, req, http.StatusOK) + var apiResp *api.Compare + DecodeJSON(t, resp, &apiResp) - var apiResp *api.Compare - DecodeJSON(t, resp, &apiResp) + assert.Equal(t, 2, apiResp.TotalCommits) + assert.Len(t, apiResp.Commits, 2) + }) - assert.Equal(t, 2, apiResp.TotalCommits) - assert.Len(t, apiResp.Commits, 2) + t.Run("CompareCommits", func(t *testing.T) { + defer tests.PrintCurrentTest(t)() + req := NewRequestf(t, "GET", "/api/v1/repos/user2/repo20/compare/808038d2f71b0ab02099...c8e31bc7688741a5287f").AddTokenAuth(token) + resp := MakeRequest(t, req, http.StatusOK) + + var apiResp *api.Compare + DecodeJSON(t, resp, &apiResp) + + assert.Equal(t, 1, apiResp.TotalCommits) + assert.Len(t, apiResp.Commits, 1) + }) } |