From 22f2853429d4355e16bc7ec16e6510a6acfc6b1e Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Tue, 29 Mar 2022 07:09:57 +0800 Subject: [PATCH] Use goproxy.io instead of goproxy.cn (#574) Fix CI, Fix #572 Reviewed-on: https://gitea.com/gitea/go-sdk/pulls/574 Reviewed-by: techknowlogick Reviewed-by: John Olheiser Co-authored-by: Lunny Xiao Co-committed-by: Lunny Xiao --- .drone.yml | 6 +++--- gitea/admin_test.go | 2 +- gitea/notifications_test.go | 12 ++++++------ gitea/release_test.go | 2 +- gitea/repo_collaborator_test.go | 4 ++-- gitea/repo_transfer_test.go | 7 ++++--- gitea/settings_test.go | 2 +- gitea/user_settings_test.go | 4 ++-- gitea/user_test.go | 2 +- 9 files changed, 21 insertions(+), 20 deletions(-) diff --git a/.drone.yml b/.drone.yml index 70741e5..421fc20 100644 --- a/.drone.yml +++ b/.drone.yml @@ -14,11 +14,11 @@ steps: - name: gitea image: gitea/gitea:dev detach: true - user: gitea commands: - mkdir -p /tmp/conf/ - mkdir -p /tmp/data/ - - echo "[security]" > /tmp/conf/app.ini + - echo "I_AM_BEING_UNSAFE_RUNNING_AS_ROOT = true" > /tmp/conf/app.ini + - echo "[security]" >> /tmp/conf/app.ini - echo "INTERNAL_TOKEN = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE1NTg4MzY4ODB9.LoKQyK5TN_0kMJFVHWUW0uDAyoGjDP6Mkup4ps2VJN4" >> /tmp/conf/app.ini - echo "INSTALL_LOCK = true" >> /tmp/conf/app.ini - echo "SECRET_KEY = 2crAW4UANgvLipDS6U5obRcFosjSJHQANll6MNfX7P0G3se3fKcCwwK3szPyGcbo" >> /tmp/conf/app.ini @@ -37,7 +37,7 @@ steps: pull: always image: golang:1.16 environment: - GOPROXY: "https://goproxy.cn" + GOPROXY: "https://goproxy.io" GO111MODULE: "on" HTTP_PROXY: "" GITEA_SDK_TEST_URL: "http://gitea:3000" diff --git a/gitea/admin_test.go b/gitea/admin_test.go index 041040f..cbb67c9 100644 --- a/gitea/admin_test.go +++ b/gitea/admin_test.go @@ -45,7 +45,7 @@ func TestAdminCronTasks(t *testing.T) { tasks, _, err := c.ListCronTasks(ListCronTaskOptions{}) assert.NoError(t, err) - assert.Len(t, tasks, 18) + assert.Len(t, tasks, 19) _, err = c.RunCronTasks(tasks[0].Name) assert.NoError(t, err) } diff --git a/gitea/notifications_test.go b/gitea/notifications_test.go index 96abc4b..1f86bf4 100644 --- a/gitea/notifications_test.go +++ b/gitea/notifications_test.go @@ -23,7 +23,7 @@ func TestNotifications(t *testing.T) { assert.NoError(t, err) user2 := createTestUser(t, "notify2", c) - //create 2 repos + // create 2 repos repoA, err := createTestRepo(t, "TestNotifications_A", c) assert.NoError(t, err) @@ -118,16 +118,16 @@ func TestNotifications(t *testing.T) { _, _ = c.DeleteRepo("test01", "Reviews") nList, _, err = c.ListNotifications(ListNotificationOptions{Status: []NotifyStatus{NotifyStatusRead}}) assert.NoError(t, err) - assert.Len(t, nList, 4) + assert.Len(t, nList, 2) - _, err = c.ReadNotification(nList[2].ID, NotifyStatusPinned) + _, err = c.ReadNotification(nList[0].ID, NotifyStatusPinned) assert.NoError(t, err) - _, err = c.ReadNotification(nList[3].ID, NotifyStatusUnread) + _, err = c.ReadNotification(nList[1].ID, NotifyStatusUnread) assert.NoError(t, err) nList, _, err = c.ListNotifications(ListNotificationOptions{Status: []NotifyStatus{NotifyStatusPinned, NotifyStatusUnread}}) assert.NoError(t, err) if assert.Len(t, nList, 2) { - assert.EqualValues(t, NotifySubjectClosed, nList[0].Subject.State) - assert.EqualValues(t, NotifySubjectClosed, nList[1].Subject.State) + assert.EqualValues(t, NotifySubjectOpen, nList[0].Subject.State) + assert.EqualValues(t, NotifySubjectOpen, nList[1].Subject.State) } } diff --git a/gitea/release_test.go b/gitea/release_test.go index 6025554..a7afbf6 100644 --- a/gitea/release_test.go +++ b/gitea/release_test.go @@ -57,7 +57,7 @@ func TestRelease(t *testing.T) { IsPreRelease: &tr, }) assert.NoError(t, err) - assert.Len(t, rl, 0) // created release is a pre-release + assert.Len(t, rl, 1) // created release is a pre-release // test fallback r2, _, err = c.fallbackGetReleaseByTag(repo.Owner.UserName, repo.Name, r.TagName) assert.NoError(t, err) diff --git a/gitea/repo_collaborator_test.go b/gitea/repo_collaborator_test.go index b320b6a..d059ba8 100644 --- a/gitea/repo_collaborator_test.go +++ b/gitea/repo_collaborator_test.go @@ -41,8 +41,8 @@ func TestRepoCollaborator(t *testing.T) { reviewers, _, err := c.GetReviewers(repo.Owner.UserName, repo.Name) assert.NoError(t, err) - assert.Len(t, reviewers, 2) - assert.EqualValues(t, []string{"ping", "pong"}, userToStringSlice(reviewers)) + assert.Len(t, reviewers, 3) + assert.EqualValues(t, []string{"ping", "pong", "test01"}, userToStringSlice(reviewers)) assignees, _, err := c.GetAssignees(repo.Owner.UserName, repo.Name) assert.NoError(t, err) diff --git a/gitea/repo_transfer_test.go b/gitea/repo_transfer_test.go index d29d035..11fe411 100644 --- a/gitea/repo_transfer_test.go +++ b/gitea/repo_transfer_test.go @@ -21,18 +21,19 @@ func TestRepoTransfer(t *testing.T) { assert.NoError(t, err) newRepo, _, err := c.TransferRepo(repo.Owner.UserName, repo.Name, TransferRepoOption{NewOwner: org.UserName}) - assert.NoError(t, err) + assert.NoError(t, err) // admin transfer repository will execute immediately but not set as pendding. assert.NotNil(t, newRepo) + assert.EqualValues(t, "ToMove", newRepo.Name) repo, err = createTestRepo(t, "ToMove", c) assert.NoError(t, err) _, _, err = c.TransferRepo(repo.Owner.UserName, repo.Name, TransferRepoOption{NewOwner: org.UserName}) - assert.Error(t, err) + assert.Error(t, err, err.Error()) // org.UserName/repo.Name has exist _, err = c.DeleteRepo(repo.Owner.UserName, repo.Name) assert.NoError(t, err) _, err = c.DeleteRepo(newRepo.Owner.UserName, newRepo.Name) - assert.NoError(t, err) + assert.Error(t, err) _, err = c.DeleteOrg(org.UserName) assert.NoError(t, err) } diff --git a/gitea/settings_test.go b/gitea/settings_test.go index d5e3e06..e75d401 100644 --- a/gitea/settings_test.go +++ b/gitea/settings_test.go @@ -41,7 +41,7 @@ func TestGetGlobalSettings(t *testing.T) { assert.NoError(t, err) assert.EqualValues(t, &GlobalAttachmentSettings{ Enabled: true, - AllowedTypes: ".docx,.gif,.gz,.jpeg,.jpg,.log,.pdf,.png,.pptx,.txt,.xlsx,.zip", + AllowedTypes: ".docx,.gif,.gz,.jpeg,.jpg,.mp4,.log,.pdf,.png,.pptx,.txt,.xlsx,.zip", MaxSize: 4, MaxFiles: 5, }, attachSettings) diff --git a/gitea/user_settings_test.go b/gitea/user_settings_test.go index 3710a60..641089b 100644 --- a/gitea/user_settings_test.go +++ b/gitea/user_settings_test.go @@ -19,7 +19,7 @@ func TestUserSettings(t *testing.T) { assert.NoError(t, err) assert.NotNil(t, userConf) assert.EqualValues(t, UserSettings{ - Theme: "gitea", + Theme: "auto", HideEmail: false, HideActivity: false, }, *userConf) @@ -33,7 +33,7 @@ func TestUserSettings(t *testing.T) { assert.NotNil(t, userConf) assert.EqualValues(t, UserSettings{ FullName: "Admin User on Test", - Theme: "gitea", + Theme: "auto", Language: "de_de", HideEmail: true, HideActivity: false, diff --git a/gitea/user_test.go b/gitea/user_test.go index 246fe8b..727fb1b 100644 --- a/gitea/user_test.go +++ b/gitea/user_test.go @@ -21,7 +21,7 @@ func TestMyUser(t *testing.T) { assert.EqualValues(t, "test01", user.UserName) assert.EqualValues(t, "test01@gitea.io", user.Email) assert.EqualValues(t, "", user.FullName) - assert.EqualValues(t, getGiteaURL()+"/user/avatar/test01/-1", user.AvatarURL) + assert.EqualValues(t, "https://secure.gravatar.com/avatar/d794373e882a68fb173cef817fb6180a?d=identicon", user.AvatarURL) assert.True(t, user.IsAdmin) }