You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

dingtalk_test.go 918B

12345678910111213141516171819202122232425262728293031
  1. // Copyright 2019 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package webhook
  5. import (
  6. "testing"
  7. api "code.gitea.io/gitea/modules/structs"
  8. "github.com/stretchr/testify/assert"
  9. "github.com/stretchr/testify/require"
  10. )
  11. func TestGetDingTalkIssuesPayload(t *testing.T) {
  12. p := issueTestPayload()
  13. p.Action = api.HookIssueOpened
  14. pl, err := getDingtalkIssuesPayload(p)
  15. require.Nil(t, err)
  16. require.NotNil(t, pl)
  17. assert.Equal(t, "#2 crash", pl.ActionCard.Title)
  18. assert.Equal(t, "[test/repo] Issue opened: #2 crash by user1\r\n\r\n", pl.ActionCard.Text)
  19. p.Action = api.HookIssueClosed
  20. pl, err = getDingtalkIssuesPayload(p)
  21. require.Nil(t, err)
  22. require.NotNil(t, pl)
  23. assert.Equal(t, "#2 crash", pl.ActionCard.Title)
  24. assert.Equal(t, "[test/repo] Issue closed: #2 crash by user1\r\n\r\n", pl.ActionCard.Text)
  25. }