merak_test.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package dao
  2. import (
  3. "context"
  4. "strings"
  5. "testing"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDaoSendWechat(t *testing.T) {
  9. convey.Convey("SendWechat", t, func(ctx convey.C) {
  10. var (
  11. content = "测试内容"
  12. title = "测试标题"
  13. )
  14. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  15. err := d.MerakNotify(context.Background(), content, title)
  16. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  17. ctx.So(err, convey.ShouldBeNil)
  18. })
  19. })
  20. })
  21. }
  22. func TestDaoGetMerakSign(t *testing.T) {
  23. convey.Convey("sign", t, func(ctx convey.C) {
  24. var (
  25. params = map[string]string{
  26. "Action": "CreateWechatMessage",
  27. "PublicKey": _publicKey,
  28. //"UserName": strings.Join(d.c.ReviewNotify.Users, ","),
  29. "UserName": strings.Join([]string{"user1", "user2"}, ","),
  30. "Title": "测试标题",
  31. "Content": "测试内容",
  32. "TreeId": "",
  33. }
  34. )
  35. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  36. p1, err := MerakSign(params)
  37. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  38. ctx.So(err, convey.ShouldBeNil)
  39. })
  40. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  41. ctx.So(p1, convey.ShouldEqual, "59cd4e74b225a7d326ee7d6c89bf27cf2f6015dc")
  42. })
  43. })
  44. })
  45. }