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.Body)
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.FormattedBody)
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)
p.Action=api.HookIssueClosed
p.Action=api.HookIssueClosed
pl,err=getMatrixIssuesPayload(p,sl)
pl,err=m.Issue(p)
require.NoError(t,err)
require.NoError(t,err)
require.NotNil(t,pl)
require.NotNil(t,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.Body)
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.FormattedBody)
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)
}
}
funcTestMatrixIssueCommentPayload(t*testing.T){
funcTestMatrixIssueCommentPayload(t*testing.T){
p:=issueCommentTestPayload()
p:=issueCommentTestPayload()
m:=new(MatrixPayloadUnsafe)
sl:=&MatrixMeta{}
pl,err:=m.IssueComment(p)
pl,err:=getMatrixIssueCommentPayload(p,sl)
require.NoError(t,err)
require.NoError(t,err)
require.NotNil(t,pl)
require.NotNil(t,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.Body)
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.FormattedBody)
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)] New comment on pull request [#2 Fix bug](http://localhost:3000/test/repo/pulls/2) by [user1](https://try.gitea.io/user1)",pl.Body)
assert.Equal(t,"[[test/repo](http://localhost:3000/test/repo)] New comment on pull request [#2 Fix bug](http://localhost:3000/test/repo/pulls/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 pull request <a href=\"http://localhost:3000/test/repo/pulls/2\">#2 Fix bug</a> by <a href=\"https://try.gitea.io/user1\">user1</a>",pl.FormattedBody)
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/2\">#2 Fix bug</a> by <a href=\"https://try.gitea.io/user1\">user1</a>",pl.(*MatrixPayloadUnsafe).FormattedBody)
}
}
funcTestMatrixReleasePayload(t*testing.T){
funcTestMatrixReleasePayload(t*testing.T){
p:=pullReleaseTestPayload()
p:=pullReleaseTestPayload()
m:=new(MatrixPayloadUnsafe)
sl:=&MatrixMeta{}
pl,err:=m.Release(p)
pl,err:=getMatrixReleasePayload(p,sl)
require.NoError(t,err)
require.NoError(t,err)
require.NotNil(t,pl)
require.NotNil(t,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.Body)
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.FormattedBody)
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)
}
}
funcTestMatrixPullRequestPayload(t*testing.T){
funcTestMatrixPullRequestPayload(t*testing.T){
p:=pullRequestTestPayload()
p:=pullRequestTestPayload()
m:=new(MatrixPayloadUnsafe)
sl:=&MatrixMeta{}
pl,err:=m.PullRequest(p)
pl,err:=getMatrixPullRequestPayload(p,sl)
require.NoError(t,err)
require.NoError(t,err)
require.NotNil(t,pl)
require.NotNil(t,pl)
assert.Equal(t,"[[test/repo](http://localhost:3000/test/repo)] Pull request opened: [#2 Fix bug](http://localhost:3000/test/repo/pulls/12) by [user1](https://try.gitea.io/user1)",pl.Body)
assert.Equal(t,"[[test/repo](http://localhost:3000/test/repo)] Pull request opened: [#2 Fix bug](http://localhost:3000/test/repo/pulls/12) by [user1](https://try.gitea.io/user1)",pl.(*MatrixPayloadUnsafe).Body)
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.Text)
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)
p.Action=api.HookIssueClosed
p.Action=api.HookIssueClosed
pl,err=getSlackIssuesPayload(p,sl)
pl,err=s.Issue(p)
require.NoError(t,err)
require.NoError(t,err)
require.NotNil(t,pl)
require.NotNil(t,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.Text)
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)
}
}
funcTestSlackIssueCommentPayload(t*testing.T){
funcTestSlackIssueCommentPayload(t*testing.T){
p:=issueCommentTestPayload()
p:=issueCommentTestPayload()
s:=new(SlackPayload)
s.Username=p.Sender.UserName
sl:=&SlackMeta{
pl,err:=s.IssueComment(p)
Username:p.Sender.UserName,
}
pl,err:=getSlackIssueCommentPayload(p,sl)
require.NoError(t,err)
require.NoError(t,err)
require.NotNil(t,pl)
require.NotNil(t,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.Text)
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>] New comment on pull request <http://localhost:3000/test/repo/pulls/2|#2 Fix bug> by <https://try.gitea.io/user1|user1>",pl.Text)
assert.Equal(t,"[<http://localhost:3000/test/repo|test/repo>] New comment on pull request <http://localhost:3000/test/repo/pulls/2|#2 Fix bug> by <https://try.gitea.io/user1|user1>",pl.(*SlackPayload).Text)
}
}
funcTestSlackReleasePayload(t*testing.T){
funcTestSlackReleasePayload(t*testing.T){
p:=pullReleaseTestPayload()
p:=pullReleaseTestPayload()
s:=new(SlackPayload)
s.Username=p.Sender.UserName
sl:=&SlackMeta{
pl,err:=s.Release(p)
Username:p.Sender.UserName,
}
pl,err:=getSlackReleasePayload(p,sl)
require.NoError(t,err)
require.NoError(t,err)
require.NotNil(t,pl)
require.NotNil(t,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.Text)
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)
}
}
funcTestSlackPullRequestPayload(t*testing.T){
funcTestSlackPullRequestPayload(t*testing.T){
p:=pullRequestTestPayload()
p:=pullRequestTestPayload()
s:=new(SlackPayload)
s.Username=p.Sender.UserName
sl:=&SlackMeta{
pl,err:=s.PullRequest(p)
Username:p.Sender.UserName,
}
pl,err:=getSlackPullRequestPayload(p,sl)
require.NoError(t,err)
require.NoError(t,err)
require.NotNil(t,pl)
require.NotNil(t,pl)
assert.Equal(t,"[<http://localhost:3000/test/repo|test/repo>] Pull request opened: <http://localhost:3000/test/repo/pulls/12|#2 Fix bug> by <https://try.gitea.io/user1|user1>",pl.Text)
assert.Equal(t,"[<http://localhost:3000/test/repo|test/repo>] Pull request opened: <http://localhost:3000/test/repo/pulls/12|#2 Fix bug> by <https://try.gitea.io/user1|user1>",pl.(*SlackPayload).Text)