Browse Source

Актуализированы тесты, которые сломались после перевода #88

dev_mirocod
Artur Galyamov 2 years ago
parent
commit
179f874d6c
  1. 12
      services/webhook/dingtalk_test.go
  2. 10
      services/webhook/discord_test.go
  3. 10
      services/webhook/feishu_test.go
  4. 14
      services/webhook/general.go
  5. 34
      services/webhook/general_test.go
  6. 20
      services/webhook/matrix_test.go
  7. 20
      services/webhook/msteams_test.go
  8. 10
      services/webhook/slack_test.go
  9. 10
      services/webhook/telegram_test.go

12
services/webhook/dingtalk_test.go

@ -96,7 +96,7 @@ func TestDingTalkPayload(t *testing.T) {
require.NotNil(t, pl)
require.IsType(t, &DingtalkPayload{}, pl)
assert.Equal(t, "[test/repo] Issue opened: #2 crash by user1\r\n\r\nissue body", pl.(*DingtalkPayload).ActionCard.Text)
assert.Equal(t, "[test/repo] Задача открыта: #2 crash by user1\r\n\r\nissue body", pl.(*DingtalkPayload).ActionCard.Text)
assert.Equal(t, "#2 crash", pl.(*DingtalkPayload).ActionCard.Title)
assert.Equal(t, "view issue", pl.(*DingtalkPayload).ActionCard.SingleTitle)
assert.Equal(t, "http://localhost:3000/test/repo/issues/2", parseRealSingleURL(pl.(*DingtalkPayload).ActionCard.SingleURL))
@ -107,7 +107,7 @@ func TestDingTalkPayload(t *testing.T) {
require.NotNil(t, pl)
require.IsType(t, &DingtalkPayload{}, pl)
assert.Equal(t, "[test/repo] Issue closed: #2 crash by user1", pl.(*DingtalkPayload).ActionCard.Text)
assert.Equal(t, "[test/repo] Задача закрыта: #2 crash by user1", pl.(*DingtalkPayload).ActionCard.Text)
assert.Equal(t, "#2 crash", pl.(*DingtalkPayload).ActionCard.Title)
assert.Equal(t, "view issue", pl.(*DingtalkPayload).ActionCard.SingleTitle)
assert.Equal(t, "http://localhost:3000/test/repo/issues/2", parseRealSingleURL(pl.(*DingtalkPayload).ActionCard.SingleURL))
@ -122,7 +122,7 @@ func TestDingTalkPayload(t *testing.T) {
require.NotNil(t, pl)
require.IsType(t, &DingtalkPayload{}, pl)
assert.Equal(t, "[test/repo] New comment on issue #2 crash by user1\r\n\r\nmore info needed", pl.(*DingtalkPayload).ActionCard.Text)
assert.Equal(t, "[test/repo] Новый комментарий на issue #2 crash by user1\r\n\r\nmore info needed", pl.(*DingtalkPayload).ActionCard.Text)
assert.Equal(t, "#2 crash", pl.(*DingtalkPayload).ActionCard.Title)
assert.Equal(t, "view issue comment", pl.(*DingtalkPayload).ActionCard.SingleTitle)
assert.Equal(t, "http://localhost:3000/test/repo/issues/2#issuecomment-4", parseRealSingleURL(pl.(*DingtalkPayload).ActionCard.SingleURL))
@ -152,7 +152,7 @@ func TestDingTalkPayload(t *testing.T) {
require.NotNil(t, pl)
require.IsType(t, &DingtalkPayload{}, pl)
assert.Equal(t, "[test/repo] New comment on pull request #12 Fix bug by user1\r\n\r\nchanges requested", pl.(*DingtalkPayload).ActionCard.Text)
assert.Equal(t, "[test/repo] Новый комментарий на pull request #12 Fix bug by user1\r\n\r\nchanges requested", pl.(*DingtalkPayload).ActionCard.Text)
assert.Equal(t, "#12 Fix bug", pl.(*DingtalkPayload).ActionCard.Title)
assert.Equal(t, "view issue comment", pl.(*DingtalkPayload).ActionCard.SingleTitle)
assert.Equal(t, "http://localhost:3000/test/repo/pulls/12#issuecomment-4", parseRealSingleURL(pl.(*DingtalkPayload).ActionCard.SingleURL))
@ -198,8 +198,8 @@ func TestDingTalkPayload(t *testing.T) {
require.NotNil(t, pl)
require.IsType(t, &DingtalkPayload{}, pl)
assert.Equal(t, "[test/repo] Release created: v1.0 by user1", pl.(*DingtalkPayload).ActionCard.Text)
assert.Equal(t, "[test/repo] Release created: v1.0 by user1", pl.(*DingtalkPayload).ActionCard.Title)
assert.Equal(t, "[test/repo] Выпуск создан: v1.0 by user1", pl.(*DingtalkPayload).ActionCard.Text)
assert.Equal(t, "[test/repo] Выпуск создан: v1.0 by user1", pl.(*DingtalkPayload).ActionCard.Title)
assert.Equal(t, "view release", pl.(*DingtalkPayload).ActionCard.SingleTitle)
assert.Equal(t, "http://localhost:3000/api/v1/repos/test/repo/releases/2", parseRealSingleURL(pl.(*DingtalkPayload).ActionCard.SingleURL))
})

10
services/webhook/discord_test.go

@ -99,7 +99,7 @@ func TestDiscordPayload(t *testing.T) {
require.IsType(t, &DiscordPayload{}, pl)
assert.Len(t, pl.(*DiscordPayload).Embeds, 1)
assert.Equal(t, "[test/repo] Issue opened: #2 crash", pl.(*DiscordPayload).Embeds[0].Title)
assert.Equal(t, "[test/repo] Задача открыта: #2 crash", pl.(*DiscordPayload).Embeds[0].Title)
assert.Equal(t, "issue body", pl.(*DiscordPayload).Embeds[0].Description)
assert.Equal(t, "http://localhost:3000/test/repo/issues/2", pl.(*DiscordPayload).Embeds[0].URL)
assert.Equal(t, p.Sender.UserName, pl.(*DiscordPayload).Embeds[0].Author.Name)
@ -113,7 +113,7 @@ func TestDiscordPayload(t *testing.T) {
require.IsType(t, &DiscordPayload{}, pl)
assert.Len(t, pl.(*DiscordPayload).Embeds, 1)
assert.Equal(t, "[test/repo] Issue closed: #2 crash", pl.(*DiscordPayload).Embeds[0].Title)
assert.Equal(t, "[test/repo] Задача закрыта: #2 crash", pl.(*DiscordPayload).Embeds[0].Title)
assert.Empty(t, pl.(*DiscordPayload).Embeds[0].Description)
assert.Equal(t, "http://localhost:3000/test/repo/issues/2", pl.(*DiscordPayload).Embeds[0].URL)
assert.Equal(t, p.Sender.UserName, pl.(*DiscordPayload).Embeds[0].Author.Name)
@ -131,7 +131,7 @@ func TestDiscordPayload(t *testing.T) {
require.IsType(t, &DiscordPayload{}, pl)
assert.Len(t, pl.(*DiscordPayload).Embeds, 1)
assert.Equal(t, "[test/repo] New comment on issue #2 crash", pl.(*DiscordPayload).Embeds[0].Title)
assert.Equal(t, "[test/repo] Новый комментарий на issue #2 crash", pl.(*DiscordPayload).Embeds[0].Title)
assert.Equal(t, "more info needed", pl.(*DiscordPayload).Embeds[0].Description)
assert.Equal(t, "http://localhost:3000/test/repo/issues/2#issuecomment-4", pl.(*DiscordPayload).Embeds[0].URL)
assert.Equal(t, p.Sender.UserName, pl.(*DiscordPayload).Embeds[0].Author.Name)
@ -167,7 +167,7 @@ func TestDiscordPayload(t *testing.T) {
require.IsType(t, &DiscordPayload{}, pl)
assert.Len(t, pl.(*DiscordPayload).Embeds, 1)
assert.Equal(t, "[test/repo] New comment on pull request #12 Fix bug", pl.(*DiscordPayload).Embeds[0].Title)
assert.Equal(t, "[test/repo] Новый комментарий на pull request #12 Fix bug", pl.(*DiscordPayload).Embeds[0].Title)
assert.Equal(t, "changes requested", pl.(*DiscordPayload).Embeds[0].Description)
assert.Equal(t, "http://localhost:3000/test/repo/pulls/12#issuecomment-4", pl.(*DiscordPayload).Embeds[0].URL)
assert.Equal(t, p.Sender.UserName, pl.(*DiscordPayload).Embeds[0].Author.Name)
@ -222,7 +222,7 @@ func TestDiscordPayload(t *testing.T) {
require.IsType(t, &DiscordPayload{}, pl)
assert.Len(t, pl.(*DiscordPayload).Embeds, 1)
assert.Equal(t, "[test/repo] Release created: v1.0", pl.(*DiscordPayload).Embeds[0].Title)
assert.Equal(t, "[test/repo] Выпуск создан: v1.0", pl.(*DiscordPayload).Embeds[0].Title)
assert.Equal(t, "Note of first stable release", pl.(*DiscordPayload).Embeds[0].Description)
assert.Equal(t, "http://localhost:3000/api/v1/repos/test/repo/releases/2", pl.(*DiscordPayload).Embeds[0].URL)
assert.Equal(t, p.Sender.UserName, pl.(*DiscordPayload).Embeds[0].Author.Name)

10
services/webhook/feishu_test.go

@ -73,7 +73,7 @@ func TestFeishuPayload(t *testing.T) {
require.NotNil(t, pl)
require.IsType(t, &FeishuPayload{}, pl)
assert.Equal(t, "#2 crash\r\n[test/repo] Issue opened: #2 crash by user1\r\n\r\nissue body", pl.(*FeishuPayload).Content.Text)
assert.Equal(t, "#2 crash\r\n[test/repo] Задача открыта: #2 crash by user1\r\n\r\nissue body", pl.(*FeishuPayload).Content.Text)
p.Action = api.HookIssueClosed
pl, err = d.Issue(p)
@ -81,7 +81,7 @@ func TestFeishuPayload(t *testing.T) {
require.NotNil(t, pl)
require.IsType(t, &FeishuPayload{}, pl)
assert.Equal(t, "#2 crash\r\n[test/repo] Issue closed: #2 crash by user1", pl.(*FeishuPayload).Content.Text)
assert.Equal(t, "#2 crash\r\n[test/repo] Задача закрыта: #2 crash by user1", pl.(*FeishuPayload).Content.Text)
})
t.Run("IssueComment", func(t *testing.T) {
@ -93,7 +93,7 @@ func TestFeishuPayload(t *testing.T) {
require.NotNil(t, pl)
require.IsType(t, &FeishuPayload{}, pl)
assert.Equal(t, "#2 crash\r\n[test/repo] New comment on issue #2 crash by user1\r\n\r\nmore info needed", pl.(*FeishuPayload).Content.Text)
assert.Equal(t, "#2 crash\r\n[test/repo] Новый комментарий на issue #2 crash by user1\r\n\r\nmore info needed", pl.(*FeishuPayload).Content.Text)
})
t.Run("PullRequest", func(t *testing.T) {
@ -117,7 +117,7 @@ func TestFeishuPayload(t *testing.T) {
require.NotNil(t, pl)
require.IsType(t, &FeishuPayload{}, pl)
assert.Equal(t, "#12 Fix bug\r\n[test/repo] New comment on pull request #12 Fix bug by user1\r\n\r\nchanges requested", pl.(*FeishuPayload).Content.Text)
assert.Equal(t, "#12 Fix bug\r\n[test/repo] Новый комментарий на pull request #12 Fix bug by user1\r\n\r\nchanges requested", pl.(*FeishuPayload).Content.Text)
})
t.Run("Review", func(t *testing.T) {
@ -154,7 +154,7 @@ func TestFeishuPayload(t *testing.T) {
require.NotNil(t, pl)
require.IsType(t, &FeishuPayload{}, pl)
assert.Equal(t, "[test/repo] Release created: v1.0 by user1", pl.(*FeishuPayload).Content.Text)
assert.Equal(t, "[test/repo] Выпуск создан: v1.0 by user1", pl.(*FeishuPayload).Content.Text)
})
}

14
services/webhook/general.go

@ -53,7 +53,7 @@ func getIssuesPayloadInfo(p *api.IssuePayload, linkFormatter linkFormatter, with
text = fmt.Sprintf("[%s] Задача назначена участнику %s: %s", repoLink, strings.Join(list, ", "), titleLink)
color = greenColor
case api.HookIssueUnassigned:
text = fmt.Sprintf("[%s] Задача ни кому не назначена: %s", repoLink, titleLink)
text = fmt.Sprintf("[%s] Задача никому не назначена: %s", repoLink, titleLink)
case api.HookIssueLabelUpdated:
text = fmt.Sprintf("[%s] Обновлены метки задачи: %s", repoLink, titleLink)
case api.HookIssueLabelCleared:
@ -145,13 +145,13 @@ func getReleasePayloadInfo(p *api.ReleasePayload, linkFormatter linkFormatter, w
switch p.Action {
case api.HookReleasePublished:
text = fmt.Sprintf("[%s] Созданный релиз: %s", repoLink, refLink)
text = fmt.Sprintf("[%s] Выпуск создан: %s", repoLink, refLink)
color = greenColor
case api.HookReleaseUpdated:
text = fmt.Sprintf("[%s] Обновленный релиз: %s", repoLink, refLink)
text = fmt.Sprintf("[%s] Выпуск обновлён: %s", repoLink, refLink)
color = yellowColor
case api.HookReleaseDeleted:
text = fmt.Sprintf("[%s] Удаленный релиз: %s", repoLink, refLink)
text = fmt.Sprintf("[%s] Выпуск удалён: %s", repoLink, refLink)
color = redColor
}
if withSender {
@ -178,16 +178,16 @@ func getIssueCommentPayloadInfo(p *api.IssueCommentPayload, linkFormatter linkFo
switch p.Action {
case api.HookIssueCommentCreated:
text = fmt.Sprintf("[%s] Новый коментарий на %s %s", repoLink, typ, titleLink)
text = fmt.Sprintf("[%s] Новый комментарий на %s %s", repoLink, typ, titleLink)
if p.IsPull {
color = greenColorLight
} else {
color = orangeColorLight
}
case api.HookIssueCommentEdited:
text = fmt.Sprintf("[%s] Комментарий изменен на %s %s", repoLink, typ, titleLink)
text = fmt.Sprintf("[%s] Комментарий изменён на %s %s", repoLink, typ, titleLink)
case api.HookIssueCommentDeleted:
text = fmt.Sprintf("[%s] Комментарий удален на %s %s", repoLink, typ, titleLink)
text = fmt.Sprintf("[%s] Комментарий удалён на %s %s", repoLink, typ, titleLink)
color = redColor
}
if withSender {

34
services/webhook/general_test.go

@ -283,77 +283,77 @@ func TestGetIssuesPayloadInfo(t *testing.T) {
}{
{
api.HookIssueOpened,
"[test/repo] Issue opened: #2 crash by user1",
"[test/repo] Задача открыта: #2 crash by user1",
"#2 crash",
"issue body",
orangeColor,
},
{
api.HookIssueClosed,
"[test/repo] Issue closed: #2 crash by user1",
"[test/repo] Задача закрыта: #2 crash by user1",
"#2 crash",
"",
redColor,
},
{
api.HookIssueReOpened,
"[test/repo] Issue re-opened: #2 crash by user1",
"[test/repo] Задача вновь открыта: #2 crash by user1",
"#2 crash",
"",
yellowColor,
},
{
api.HookIssueEdited,
"[test/repo] Issue edited: #2 crash by user1",
"[test/repo] Задача отредактирована: #2 crash by user1",
"#2 crash",
"issue body",
yellowColor,
},
{
api.HookIssueAssigned,
"[test/repo] Issue assigned to user1: #2 crash by user1",
"[test/repo] Задача назначена участнику user1: #2 crash by user1",
"#2 crash",
"",
greenColor,
},
{
api.HookIssueUnassigned,
"[test/repo] Issue unassigned: #2 crash by user1",
"[test/repo] Задача никому не назначена: #2 crash by user1",
"#2 crash",
"",
yellowColor,
},
{
api.HookIssueLabelUpdated,
"[test/repo] Issue labels updated: #2 crash by user1",
"[test/repo] Обновлены метки задачи: #2 crash by user1",
"#2 crash",
"",
yellowColor,
},
{
api.HookIssueLabelCleared,
"[test/repo] Issue labels cleared: #2 crash by user1",
"[test/repo] Удалены метки задачи: #2 crash by user1",
"#2 crash",
"",
yellowColor,
},
{
api.HookIssueSynchronized,
"[test/repo] Issue synchronized: #2 crash by user1",
"[test/repo] Задача синхронизирована: #2 crash by user1",
"#2 crash",
"",
yellowColor,
},
{
api.HookIssueMilestoned,
"[test/repo] Issue milestoned to Milestone Title: #2 crash by user1",
"[test/repo] Контрольные показатели задачи выданы для Milestone Title: #2 crash by user1",
"#2 crash",
"",
yellowColor,
},
{
api.HookIssueDemilestoned,
"[test/repo] Issue milestone cleared: #2 crash by user1",
"[test/repo] Контрольная точка задачи устранена: #2 crash by user1",
"#2 crash",
"",
yellowColor,
@ -479,17 +479,17 @@ func TestGetReleasePayloadInfo(t *testing.T) {
}{
{
api.HookReleasePublished,
"[test/repo] Release created: v1.0 by user1",
"[test/repo] Выпуск создан: v1.0 by user1",
greenColor,
},
{
api.HookReleaseUpdated,
"[test/repo] Release updated: v1.0 by user1",
"[test/repo] Выпуск обновлён: v1.0 by user1",
yellowColor,
},
{
api.HookReleaseDeleted,
"[test/repo] Release deleted: v1.0 by user1",
"[test/repo] Выпуск удалён: v1.0 by user1",
redColor,
},
}
@ -513,19 +513,19 @@ func TestGetIssueCommentPayloadInfo(t *testing.T) {
}{
{
api.HookIssueCommentCreated,
"[test/repo] New comment on pull request #12 Fix bug by user1",
"[test/repo] Новый комментарий на pull request #12 Fix bug by user1",
"#12 Fix bug",
greenColorLight,
},
{
api.HookIssueCommentEdited,
"[test/repo] Comment edited on pull request #12 Fix bug by user1",
"[test/repo] Комментарий изменён на pull request #12 Fix bug by user1",
"#12 Fix bug",
yellowColor,
},
{
api.HookIssueCommentDeleted,
"[test/repo] Comment deleted on pull request #12 Fix bug by user1",
"[test/repo] Комментарий удалён на pull request #12 Fix bug by user1",
"#12 Fix bug",
redColor,
},

20
services/webhook/matrix_test.go

@ -77,8 +77,8 @@ func TestMatrixPayload(t *testing.T) {
require.NotNil(t, pl)
require.IsType(t, &MatrixPayloadUnsafe{}, pl)
assert.Equal(t, "[[test/repo](http://localhost:3000/test/repo)] Issue opened: [#2 crash](http://localhost:3000/test/repo/issues/2) by [user1](https://try.gitea.io/user1)", pl.(*MatrixPayloadUnsafe).Body)
assert.Equal(t, `[<a href="http://localhost:3000/test/repo">test/repo</a>] Issue opened: <a href="http://localhost:3000/test/repo/issues/2">#2 crash</a> by <a href="https://try.gitea.io/user1">user1</a>`, pl.(*MatrixPayloadUnsafe).FormattedBody)
assert.Equal(t, "[[test/repo](http://localhost:3000/test/repo)] Задача открыта: [#2 crash](http://localhost:3000/test/repo/issues/2) by [user1](https://try.gitea.io/user1)", pl.(*MatrixPayloadUnsafe).Body)
assert.Equal(t, `[<a href="http://localhost:3000/test/repo">test/repo</a>] Задача открыта: <a href="http://localhost:3000/test/repo/issues/2">#2 crash</a> by <a href="https://try.gitea.io/user1">user1</a>`, pl.(*MatrixPayloadUnsafe).FormattedBody)
p.Action = api.HookIssueClosed
pl, err = d.Issue(p)
@ -86,8 +86,8 @@ func TestMatrixPayload(t *testing.T) {
require.NotNil(t, pl)
require.IsType(t, &MatrixPayloadUnsafe{}, pl)
assert.Equal(t, "[[test/repo](http://localhost:3000/test/repo)] Issue closed: [#2 crash](http://localhost:3000/test/repo/issues/2) by [user1](https://try.gitea.io/user1)", pl.(*MatrixPayloadUnsafe).Body)
assert.Equal(t, `[<a href="http://localhost:3000/test/repo">test/repo</a>] Issue closed: <a href="http://localhost:3000/test/repo/issues/2">#2 crash</a> by <a href="https://try.gitea.io/user1">user1</a>`, pl.(*MatrixPayloadUnsafe).FormattedBody)
assert.Equal(t, "[[test/repo](http://localhost:3000/test/repo)] Задача закрыта: [#2 crash](http://localhost:3000/test/repo/issues/2) by [user1](https://try.gitea.io/user1)", pl.(*MatrixPayloadUnsafe).Body)
assert.Equal(t, `[<a href="http://localhost:3000/test/repo">test/repo</a>] Задача закрыта: <a href="http://localhost:3000/test/repo/issues/2">#2 crash</a> by <a href="https://try.gitea.io/user1">user1</a>`, pl.(*MatrixPayloadUnsafe).FormattedBody)
})
t.Run("IssueComment", func(t *testing.T) {
@ -99,8 +99,8 @@ func TestMatrixPayload(t *testing.T) {
require.NotNil(t, pl)
require.IsType(t, &MatrixPayloadUnsafe{}, pl)
assert.Equal(t, "[[test/repo](http://localhost:3000/test/repo)] New comment on issue [#2 crash](http://localhost:3000/test/repo/issues/2) by [user1](https://try.gitea.io/user1)", pl.(*MatrixPayloadUnsafe).Body)
assert.Equal(t, `[<a href="http://localhost:3000/test/repo">test/repo</a>] New comment on issue <a href="http://localhost:3000/test/repo/issues/2">#2 crash</a> by <a href="https://try.gitea.io/user1">user1</a>`, pl.(*MatrixPayloadUnsafe).FormattedBody)
assert.Equal(t, "[[test/repo](http://localhost:3000/test/repo)] Новый комментарий на issue [#2 crash](http://localhost:3000/test/repo/issues/2) by [user1](https://try.gitea.io/user1)", pl.(*MatrixPayloadUnsafe).Body)
assert.Equal(t, `[<a href="http://localhost:3000/test/repo">test/repo</a>] Новый комментарий на issue <a href="http://localhost:3000/test/repo/issues/2">#2 crash</a> by <a href="https://try.gitea.io/user1">user1</a>`, pl.(*MatrixPayloadUnsafe).FormattedBody)
})
t.Run("PullRequest", func(t *testing.T) {
@ -125,8 +125,8 @@ func TestMatrixPayload(t *testing.T) {
require.NotNil(t, pl)
require.IsType(t, &MatrixPayloadUnsafe{}, pl)
assert.Equal(t, "[[test/repo](http://localhost:3000/test/repo)] New comment on pull request [#12 Fix bug](http://localhost:3000/test/repo/pulls/12) by [user1](https://try.gitea.io/user1)", pl.(*MatrixPayloadUnsafe).Body)
assert.Equal(t, `[<a href="http://localhost:3000/test/repo">test/repo</a>] New comment on pull request <a href="http://localhost:3000/test/repo/pulls/12">#12 Fix bug</a> by <a href="https://try.gitea.io/user1">user1</a>`, pl.(*MatrixPayloadUnsafe).FormattedBody)
assert.Equal(t, "[[test/repo](http://localhost:3000/test/repo)] Новый комментарий на pull request [#12 Fix bug](http://localhost:3000/test/repo/pulls/12) by [user1](https://try.gitea.io/user1)", pl.(*MatrixPayloadUnsafe).Body)
assert.Equal(t, `[<a href="http://localhost:3000/test/repo">test/repo</a>] Новый комментарий на pull request <a href="http://localhost:3000/test/repo/pulls/12">#12 Fix bug</a> by <a href="https://try.gitea.io/user1">user1</a>`, pl.(*MatrixPayloadUnsafe).FormattedBody)
})
t.Run("Review", func(t *testing.T) {
@ -165,8 +165,8 @@ func TestMatrixPayload(t *testing.T) {
require.NotNil(t, pl)
require.IsType(t, &MatrixPayloadUnsafe{}, pl)
assert.Equal(t, "[[test/repo](http://localhost:3000/test/repo)] Release created: [v1.0](http://localhost:3000/test/repo/src/v1.0) by [user1](https://try.gitea.io/user1)", pl.(*MatrixPayloadUnsafe).Body)
assert.Equal(t, `[<a href="http://localhost:3000/test/repo">test/repo</a>] Release created: <a href="http://localhost:3000/test/repo/src/v1.0">v1.0</a> by <a href="https://try.gitea.io/user1">user1</a>`, pl.(*MatrixPayloadUnsafe).FormattedBody)
assert.Equal(t, "[[test/repo](http://localhost:3000/test/repo)] Выпуск создан: [v1.0](http://localhost:3000/test/repo/src/v1.0) by [user1](https://try.gitea.io/user1)", pl.(*MatrixPayloadUnsafe).Body)
assert.Equal(t, `[<a href="http://localhost:3000/test/repo">test/repo</a>] Выпуск создан: <a href="http://localhost:3000/test/repo/src/v1.0">v1.0</a> by <a href="https://try.gitea.io/user1">user1</a>`, pl.(*MatrixPayloadUnsafe).FormattedBody)
})
}

20
services/webhook/msteams_test.go

@ -141,8 +141,8 @@ func TestMSTeamsPayload(t *testing.T) {
require.NotNil(t, pl)
require.IsType(t, &MSTeamsPayload{}, pl)
assert.Equal(t, "[test/repo] Issue opened: #2 crash", pl.(*MSTeamsPayload).Title)
assert.Equal(t, "[test/repo] Issue opened: #2 crash", pl.(*MSTeamsPayload).Summary)
assert.Equal(t, "[test/repo] Задача открыта: #2 crash", pl.(*MSTeamsPayload).Title)
assert.Equal(t, "[test/repo] Задача открыта: #2 crash", pl.(*MSTeamsPayload).Summary)
assert.Len(t, pl.(*MSTeamsPayload).Sections, 1)
assert.Equal(t, "user1", pl.(*MSTeamsPayload).Sections[0].ActivitySubtitle)
assert.Equal(t, "issue body", pl.(*MSTeamsPayload).Sections[0].Text)
@ -166,8 +166,8 @@ func TestMSTeamsPayload(t *testing.T) {
require.NotNil(t, pl)
require.IsType(t, &MSTeamsPayload{}, pl)
assert.Equal(t, "[test/repo] Issue closed: #2 crash", pl.(*MSTeamsPayload).Title)
assert.Equal(t, "[test/repo] Issue closed: #2 crash", pl.(*MSTeamsPayload).Summary)
assert.Equal(t, "[test/repo] Задача закрыта: #2 crash", pl.(*MSTeamsPayload).Title)
assert.Equal(t, "[test/repo] Задача закрыта: #2 crash", pl.(*MSTeamsPayload).Summary)
assert.Len(t, pl.(*MSTeamsPayload).Sections, 1)
assert.Equal(t, "user1", pl.(*MSTeamsPayload).Sections[0].ActivitySubtitle)
assert.Empty(t, pl.(*MSTeamsPayload).Sections[0].Text)
@ -195,8 +195,8 @@ func TestMSTeamsPayload(t *testing.T) {
require.NotNil(t, pl)
require.IsType(t, &MSTeamsPayload{}, pl)
assert.Equal(t, "[test/repo] New comment on issue #2 crash", pl.(*MSTeamsPayload).Title)
assert.Equal(t, "[test/repo] New comment on issue #2 crash", pl.(*MSTeamsPayload).Summary)
assert.Equal(t, "[test/repo] Новый комментарий на issue #2 crash", pl.(*MSTeamsPayload).Title)
assert.Equal(t, "[test/repo] Новый комментарий на issue #2 crash", pl.(*MSTeamsPayload).Summary)
assert.Len(t, pl.(*MSTeamsPayload).Sections, 1)
assert.Equal(t, "user1", pl.(*MSTeamsPayload).Sections[0].ActivitySubtitle)
assert.Equal(t, "more info needed", pl.(*MSTeamsPayload).Sections[0].Text)
@ -253,8 +253,8 @@ func TestMSTeamsPayload(t *testing.T) {
require.NotNil(t, pl)
require.IsType(t, &MSTeamsPayload{}, pl)
assert.Equal(t, "[test/repo] New comment on pull request #12 Fix bug", pl.(*MSTeamsPayload).Title)
assert.Equal(t, "[test/repo] New comment on pull request #12 Fix bug", pl.(*MSTeamsPayload).Summary)
assert.Equal(t, "[test/repo] Новый комментарий на pull request #12 Fix bug", pl.(*MSTeamsPayload).Title)
assert.Equal(t, "[test/repo] Новый комментарий на pull request #12 Fix bug", pl.(*MSTeamsPayload).Summary)
assert.Len(t, pl.(*MSTeamsPayload).Sections, 1)
assert.Equal(t, "user1", pl.(*MSTeamsPayload).Sections[0].ActivitySubtitle)
assert.Equal(t, "changes requested", pl.(*MSTeamsPayload).Sections[0].Text)
@ -339,8 +339,8 @@ func TestMSTeamsPayload(t *testing.T) {
require.NotNil(t, pl)
require.IsType(t, &MSTeamsPayload{}, pl)
assert.Equal(t, "[test/repo] Release created: v1.0", pl.(*MSTeamsPayload).Title)
assert.Equal(t, "[test/repo] Release created: v1.0", pl.(*MSTeamsPayload).Summary)
assert.Equal(t, "[test/repo] Выпуск создан: v1.0", pl.(*MSTeamsPayload).Title)
assert.Equal(t, "[test/repo] Выпуск создан: v1.0", pl.(*MSTeamsPayload).Summary)
assert.Len(t, pl.(*MSTeamsPayload).Sections, 1)
assert.Equal(t, "user1", pl.(*MSTeamsPayload).Sections[0].ActivitySubtitle)
assert.Empty(t, pl.(*MSTeamsPayload).Sections[0].Text)

10
services/webhook/slack_test.go

@ -73,7 +73,7 @@ func TestSlackPayload(t *testing.T) {
require.NotNil(t, pl)
require.IsType(t, &SlackPayload{}, pl)
assert.Equal(t, "[<http://localhost:3000/test/repo|test/repo>] Issue opened: <http://localhost:3000/test/repo/issues/2|#2 crash> by <https://try.gitea.io/user1|user1>", pl.(*SlackPayload).Text)
assert.Equal(t, "[<http://localhost:3000/test/repo|test/repo>] Задача открыта: <http://localhost:3000/test/repo/issues/2|#2 crash> by <https://try.gitea.io/user1|user1>", pl.(*SlackPayload).Text)
p.Action = api.HookIssueClosed
pl, err = d.Issue(p)
@ -81,7 +81,7 @@ func TestSlackPayload(t *testing.T) {
require.NotNil(t, pl)
require.IsType(t, &SlackPayload{}, pl)
assert.Equal(t, "[<http://localhost:3000/test/repo|test/repo>] Issue closed: <http://localhost:3000/test/repo/issues/2|#2 crash> by <https://try.gitea.io/user1|user1>", pl.(*SlackPayload).Text)
assert.Equal(t, "[<http://localhost:3000/test/repo|test/repo>] Задача закрыта: <http://localhost:3000/test/repo/issues/2|#2 crash> by <https://try.gitea.io/user1|user1>", pl.(*SlackPayload).Text)
})
t.Run("IssueComment", func(t *testing.T) {
@ -93,7 +93,7 @@ func TestSlackPayload(t *testing.T) {
require.NotNil(t, pl)
require.IsType(t, &SlackPayload{}, pl)
assert.Equal(t, "[<http://localhost:3000/test/repo|test/repo>] New comment on issue <http://localhost:3000/test/repo/issues/2|#2 crash> by <https://try.gitea.io/user1|user1>", pl.(*SlackPayload).Text)
assert.Equal(t, "[<http://localhost:3000/test/repo|test/repo>] Новый комментарий на issue <http://localhost:3000/test/repo/issues/2|#2 crash> by <https://try.gitea.io/user1|user1>", pl.(*SlackPayload).Text)
})
t.Run("PullRequest", func(t *testing.T) {
@ -117,7 +117,7 @@ func TestSlackPayload(t *testing.T) {
require.NotNil(t, pl)
require.IsType(t, &SlackPayload{}, pl)
assert.Equal(t, "[<http://localhost:3000/test/repo|test/repo>] New comment on pull request <http://localhost:3000/test/repo/pulls/12|#12 Fix bug> by <https://try.gitea.io/user1|user1>", pl.(*SlackPayload).Text)
assert.Equal(t, "[<http://localhost:3000/test/repo|test/repo>] Новый комментарий на pull request <http://localhost:3000/test/repo/pulls/12|#12 Fix bug> by <https://try.gitea.io/user1|user1>", pl.(*SlackPayload).Text)
})
t.Run("Review", func(t *testing.T) {
@ -154,7 +154,7 @@ func TestSlackPayload(t *testing.T) {
require.NotNil(t, pl)
require.IsType(t, &SlackPayload{}, pl)
assert.Equal(t, "[<http://localhost:3000/test/repo|test/repo>] Release created: <http://localhost:3000/test/repo/src/v1.0|v1.0> by <https://try.gitea.io/user1|user1>", pl.(*SlackPayload).Text)
assert.Equal(t, "[<http://localhost:3000/test/repo|test/repo>] Выпуск создан: <http://localhost:3000/test/repo/src/v1.0|v1.0> by <https://try.gitea.io/user1|user1>", pl.(*SlackPayload).Text)
})
}

10
services/webhook/telegram_test.go

@ -73,7 +73,7 @@ func TestTelegramPayload(t *testing.T) {
require.NotNil(t, pl)
require.IsType(t, &TelegramPayload{}, pl)
assert.Equal(t, "[<a href=\"http://localhost:3000/test/repo\">test/repo</a>] Issue opened: <a href=\"http://localhost:3000/test/repo/issues/2\">#2 crash</a> by <a href=\"https://try.gitea.io/user1\">user1</a>\n\nissue body", pl.(*TelegramPayload).Message)
assert.Equal(t, "[<a href=\"http://localhost:3000/test/repo\">test/repo</a>] Задача открыта: <a href=\"http://localhost:3000/test/repo/issues/2\">#2 crash</a> by <a href=\"https://try.gitea.io/user1\">user1</a>\n\nissue body", pl.(*TelegramPayload).Message)
p.Action = api.HookIssueClosed
pl, err = d.Issue(p)
@ -81,7 +81,7 @@ func TestTelegramPayload(t *testing.T) {
require.NotNil(t, pl)
require.IsType(t, &TelegramPayload{}, pl)
assert.Equal(t, `[<a href="http://localhost:3000/test/repo">test/repo</a>] Issue closed: <a href="http://localhost:3000/test/repo/issues/2">#2 crash</a> by <a href="https://try.gitea.io/user1">user1</a>`, pl.(*TelegramPayload).Message)
assert.Equal(t, `[<a href="http://localhost:3000/test/repo">test/repo</a>] Задача закрыта: <a href="http://localhost:3000/test/repo/issues/2">#2 crash</a> by <a href="https://try.gitea.io/user1">user1</a>`, pl.(*TelegramPayload).Message)
})
t.Run("IssueComment", func(t *testing.T) {
@ -93,7 +93,7 @@ func TestTelegramPayload(t *testing.T) {
require.NotNil(t, pl)
require.IsType(t, &TelegramPayload{}, pl)
assert.Equal(t, "[<a href=\"http://localhost:3000/test/repo\">test/repo</a>] New comment on issue <a href=\"http://localhost:3000/test/repo/issues/2\">#2 crash</a> by <a href=\"https://try.gitea.io/user1\">user1</a>\nmore info needed", pl.(*TelegramPayload).Message)
assert.Equal(t, "[<a href=\"http://localhost:3000/test/repo\">test/repo</a>] Новый комментарий на issue <a href=\"http://localhost:3000/test/repo/issues/2\">#2 crash</a> by <a href=\"https://try.gitea.io/user1\">user1</a>\nmore info needed", pl.(*TelegramPayload).Message)
})
t.Run("PullRequest", func(t *testing.T) {
@ -117,7 +117,7 @@ func TestTelegramPayload(t *testing.T) {
require.NotNil(t, pl)
require.IsType(t, &TelegramPayload{}, pl)
assert.Equal(t, "[<a href=\"http://localhost:3000/test/repo\">test/repo</a>] New comment on pull request <a href=\"http://localhost:3000/test/repo/pulls/12\">#12 Fix bug</a> by <a href=\"https://try.gitea.io/user1\">user1</a>\nchanges requested", pl.(*TelegramPayload).Message)
assert.Equal(t, "[<a href=\"http://localhost:3000/test/repo\">test/repo</a>] Новый комментарий на pull request <a href=\"http://localhost:3000/test/repo/pulls/12\">#12 Fix bug</a> by <a href=\"https://try.gitea.io/user1\">user1</a>\nchanges requested", pl.(*TelegramPayload).Message)
})
t.Run("Review", func(t *testing.T) {
@ -154,7 +154,7 @@ func TestTelegramPayload(t *testing.T) {
require.NotNil(t, pl)
require.IsType(t, &TelegramPayload{}, pl)
assert.Equal(t, `[<a href="http://localhost:3000/test/repo">test/repo</a>] Release created: <a href="http://localhost:3000/test/repo/src/v1.0">v1.0</a> by <a href="https://try.gitea.io/user1">user1</a>`, pl.(*TelegramPayload).Message)
assert.Equal(t, `[<a href="http://localhost:3000/test/repo">test/repo</a>] Выпуск создан: <a href="http://localhost:3000/test/repo/src/v1.0">v1.0</a> by <a href="https://try.gitea.io/user1">user1</a>`, pl.(*TelegramPayload).Message)
})
}

Loading…
Cancel
Save