aboutsummaryrefslogtreecommitdiffstats
path: root/integrations/api_branch_test.go
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2021-04-16 20:30:16 +0200
committerGitHub <noreply@github.com>2021-04-16 20:30:16 +0200
commita67861b4dc7809e025240f18a5d60b10c6dcd6b5 (patch)
tree691dbe44218d10b930b978e40745b872d8fe59a6 /integrations/api_branch_test.go
parentc29e85228ff3b524cbe0cd4c8893109c4facc022 (diff)
downloadgitea-a67861b4dc7809e025240f18a5d60b10c6dcd6b5.tar.gz
gitea-a67861b4dc7809e025240f18a5d60b10c6dcd6b5.zip
Fix Benchmark tests, remove a broken one & add two new (#15250)
* Benchmark Integration TESTS * CI: add benching-arm64 pipeline * BenchmarkRepo: name test case tests * Fix BenchmarkRepoBranchCommit beside Create new Branch * CI: benching use amd64 * rm total broken "BenchmarkRepo" * dont run benchmark in CI
Diffstat (limited to 'integrations/api_branch_test.go')
-rw-r--r--integrations/api_branch_test.go32
1 files changed, 19 insertions, 13 deletions
diff --git a/integrations/api_branch_test.go b/integrations/api_branch_test.go
index 26d8fb4b45..d898266afe 100644
--- a/integrations/api_branch_test.go
+++ b/integrations/api_branch_test.go
@@ -151,22 +151,28 @@ func testAPICreateBranches(t *testing.T, giteaURL *url.URL) {
for _, test := range tests {
defer resetFixtures(t)
session := ctx.Session
- token := getTokenForLoggedInUser(t, session)
- req := NewRequestWithJSON(t, "POST", "/api/v1/repos/user2/my-noo-repo/branches?token="+token, &api.CreateBranchRepoOption{
- BranchName: test.NewBranch,
- OldBranchName: test.OldBranch,
- })
- resp := session.MakeRequest(t, req, test.ExpectedHTTPStatus)
-
- var branch api.Branch
- DecodeJSON(t, resp, &branch)
-
- if test.ExpectedHTTPStatus == http.StatusCreated {
- assert.EqualValues(t, test.NewBranch, branch.Name)
- }
+ testAPICreateBranch(t, session, "user2", "my-noo-repo", test.OldBranch, test.NewBranch, test.ExpectedHTTPStatus)
}
}
+func testAPICreateBranch(t testing.TB, session *TestSession, user, repo, oldBranch, newBranch string, status int) bool {
+ token := getTokenForLoggedInUser(t, session)
+ req := NewRequestWithJSON(t, "POST", "/api/v1/repos/"+user+"/"+repo+"/branches?token="+token, &api.CreateBranchRepoOption{
+ BranchName: newBranch,
+ OldBranchName: oldBranch,
+ })
+ resp := session.MakeRequest(t, req, status)
+
+ var branch api.Branch
+ DecodeJSON(t, resp, &branch)
+
+ if status == http.StatusCreated {
+ assert.EqualValues(t, newBranch, branch.Name)
+ }
+
+ return resp.Result().StatusCode == status
+}
+
func TestAPIBranchProtection(t *testing.T) {
defer prepareTestEnv(t)()