aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2024-12-30 01:25:49 +0800
committerGitHub <noreply@github.com>2024-12-30 01:25:49 +0800
commit1dbf0d7f0822c10b379a21c192c2d63e34fd52f9 (patch)
tree5c33f66ca2769dd3201ac9b4c2a532a7f57d7619
parenta96776b3cbaf69a812677d3b49b41ab3eb8ac860 (diff)
downloadgitea-1dbf0d7f0822c10b379a21c192c2d63e34fd52f9.tar.gz
gitea-1dbf0d7f0822c10b379a21c192c2d63e34fd52f9.zip
Test webhook email (#33033)
Close #27918
-rw-r--r--services/webhook/webhook_test.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/services/webhook/webhook_test.go b/services/webhook/webhook_test.go
index 63cbce1771..6bac02712b 100644
--- a/services/webhook/webhook_test.go
+++ b/services/webhook/webhook_test.go
@@ -9,11 +9,15 @@ import (
"code.gitea.io/gitea/models/db"
repo_model "code.gitea.io/gitea/models/repo"
"code.gitea.io/gitea/models/unittest"
+ user_model "code.gitea.io/gitea/models/user"
webhook_model "code.gitea.io/gitea/models/webhook"
+ "code.gitea.io/gitea/modules/setting"
api "code.gitea.io/gitea/modules/structs"
webhook_module "code.gitea.io/gitea/modules/webhook"
+ "code.gitea.io/gitea/services/convert"
"github.com/stretchr/testify/assert"
+ "github.com/stretchr/testify/require"
)
func TestWebhook_GetSlackHook(t *testing.T) {
@@ -77,3 +81,11 @@ func TestPrepareWebhooksBranchFilterNoMatch(t *testing.T) {
unittest.AssertNotExistsBean(t, hookTask)
}
}
+
+func TestWebhookUserMail(t *testing.T) {
+ require.NoError(t, unittest.PrepareTestDatabase())
+ setting.Service.NoReplyAddress = "no-reply.com"
+ user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1})
+ assert.Equal(t, user.GetPlaceholderEmail(), convert.ToUser(db.DefaultContext, user, nil).Email)
+ assert.Equal(t, user.Email, convert.ToUser(db.DefaultContext, user, user).Email)
+}