summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJakobDev <jakobdev@gmx.de>2024-12-19 16:11:12 +0100
committerJakobDev <jakobdev@gmx.de>2024-12-19 16:11:12 +0100
commit265174bd5e19d3687ddb9a63f2b4fde851a130b7 (patch)
tree793411d98a8b571b9e0f2843f93eba829bb65860 /tests
parentUpdate (diff)
parentUpdate dependency @playwright/test to v1.49.1 (forgejo) (#6308) (diff)
downloadforgejo-265174bd5e19d3687ddb9a63f2b4fde851a130b7.tar.xz
forgejo-265174bd5e19d3687ddb9a63f2b4fde851a130b7.zip
Merge branch 'forgejo' into repocard
Diffstat (limited to 'tests')
-rw-r--r--tests/integration/api_branch_test.go32
-rw-r--r--tests/integration/api_packages_cran_test.go8
-rw-r--r--tests/integration/integration_test.go5
3 files changed, 45 insertions, 0 deletions
diff --git a/tests/integration/api_branch_test.go b/tests/integration/api_branch_test.go
index 41b2c2efd1..aa22b15ea1 100644
--- a/tests/integration/api_branch_test.go
+++ b/tests/integration/api_branch_test.go
@@ -5,6 +5,7 @@ package integration
import (
"net/http"
+ "net/http/httptest"
"net/url"
"testing"
@@ -187,6 +188,37 @@ func testAPICreateBranch(t testing.TB, session *TestSession, user, repo, oldBran
return resp.Result().StatusCode == status
}
+func TestAPIUpdateBranch(t *testing.T) {
+ onGiteaRun(t, func(t *testing.T, _ *url.URL) {
+ t.Run("UpdateBranchWithEmptyRepo", func(t *testing.T) {
+ testAPIUpdateBranch(t, "user10", "repo6", "master", "test", http.StatusNotFound)
+ })
+ t.Run("UpdateBranchWithSameBranchNames", func(t *testing.T) {
+ resp := testAPIUpdateBranch(t, "user2", "repo1", "master", "master", http.StatusUnprocessableEntity)
+ assert.Contains(t, resp.Body.String(), "Cannot rename a branch using the same name or rename to a branch that already exists.")
+ })
+ t.Run("UpdateBranchThatAlreadyExists", func(t *testing.T) {
+ resp := testAPIUpdateBranch(t, "user2", "repo1", "master", "branch2", http.StatusUnprocessableEntity)
+ assert.Contains(t, resp.Body.String(), "Cannot rename a branch using the same name or rename to a branch that already exists.")
+ })
+ t.Run("UpdateBranchWithNonExistentBranch", func(t *testing.T) {
+ resp := testAPIUpdateBranch(t, "user2", "repo1", "i-dont-exist", "new-branch-name", http.StatusNotFound)
+ assert.Contains(t, resp.Body.String(), "Branch doesn't exist.")
+ })
+ t.Run("RenameBranchNormalScenario", func(t *testing.T) {
+ testAPIUpdateBranch(t, "user2", "repo1", "branch2", "new-branch-name", http.StatusNoContent)
+ })
+ })
+}
+
+func testAPIUpdateBranch(t *testing.T, ownerName, repoName, from, to string, expectedHTTPStatus int) *httptest.ResponseRecorder {
+ token := getUserToken(t, ownerName, auth_model.AccessTokenScopeWriteRepository)
+ req := NewRequestWithJSON(t, "PATCH", "api/v1/repos/"+ownerName+"/"+repoName+"/branches/"+from, &api.UpdateBranchRepoOption{
+ Name: to,
+ }).AddTokenAuth(token)
+ return MakeRequest(t, req, expectedHTTPStatus)
+}
+
func TestAPIBranchProtection(t *testing.T) {
defer tests.PrepareTestEnv(t)()
diff --git a/tests/integration/api_packages_cran_test.go b/tests/integration/api_packages_cran_test.go
index 31864d1ab7..d64b592327 100644
--- a/tests/integration/api_packages_cran_test.go
+++ b/tests/integration/api_packages_cran_test.go
@@ -116,6 +116,14 @@ func TestPackageCran(t *testing.T) {
MakeRequest(t, req, http.StatusOK)
})
+ t.Run("DownloadArchived", func(t *testing.T) {
+ defer tests.PrintCurrentTest(t)()
+
+ req := NewRequest(t, "GET", fmt.Sprintf("%s/src/contrib/Archive/%s/%s_%s.tar.gz", url, packageName, packageName, packageVersion)).
+ AddBasicAuth(user.Name)
+ MakeRequest(t, req, http.StatusOK)
+ })
+
t.Run("Enumerate", func(t *testing.T) {
defer tests.PrintCurrentTest(t)()
diff --git a/tests/integration/integration_test.go b/tests/integration/integration_test.go
index 606df2ed1c..65b715a688 100644
--- a/tests/integration/integration_test.go
+++ b/tests/integration/integration_test.go
@@ -166,6 +166,11 @@ func TestMain(m *testing.M) {
os.Unsetenv("GIT_COMMITTER_EMAIL")
os.Unsetenv("GIT_COMMITTER_DATE")
+ // Avoid loading the default system config. On MacOS, this config
+ // sets the osxkeychain credential helper, which will cause tests
+ // to freeze with a dialog.
+ os.Setenv("GIT_CONFIG_NOSYSTEM", "true")
+
err := unittest.InitFixtures(
unittest.FixturesOptions{
Dir: filepath.Join(filepath.Dir(setting.AppPath), "models/fixtures/"),