push_test.go 955 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package dao
  2. import (
  3. "go-common/app/interface/live/push-live/model"
  4. "testing"
  5. . "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestDao_getSign(t *testing.T) {
  8. initd()
  9. Convey("should return correct sign string by given params and secret", t, func() {
  10. params := map[string]string{
  11. "aa": "abc",
  12. "bb": "xyz",
  13. "cc": "opq",
  14. }
  15. secret := "abc"
  16. sign := d.getSign(params, secret)
  17. So(sign, ShouldEqual, "4571d284b198823bbf62f34cf38c9307")
  18. })
  19. }
  20. func TestService_GetPushTemplate(t *testing.T) {
  21. initd()
  22. Convey("should return correct template by different type", t, func() {
  23. name := "test"
  24. t1 := d.GetPushTemplate(model.AttentionGroup, name)
  25. t2 := d.GetPushTemplate(model.SpecialGroup, name)
  26. t3 := d.GetPushTemplate("test group", name)
  27. So(t1, ShouldEqual, "你关注的【test】正在直播~")
  28. So(t2, ShouldEqual, "你特别关注的【test】正在直播~")
  29. // default type template
  30. So(t3, ShouldEqual, name)
  31. })
  32. }