client_test.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. package chuanglan
  2. import (
  3. "context"
  4. "flag"
  5. "path/filepath"
  6. "testing"
  7. "go-common/app/job/main/sms/conf"
  8. "go-common/app/service/main/sms/model"
  9. . "github.com/smartystreets/goconvey/convey"
  10. )
  11. var (
  12. cl *Client
  13. sendLog = &model.ModelSend{
  14. Content: "卍 您的账号正在哔哩哔哩2018动画角色人气大赏活动中进行领票操作,验证码为5467当日有效",
  15. }
  16. )
  17. func init() {
  18. dir, _ := filepath.Abs("../../cmd/sms-job-test.toml")
  19. flag.Set("conf", dir)
  20. conf.Init()
  21. cl = NewClient(conf.Conf)
  22. }
  23. func TestGetPid(t *testing.T) {
  24. Convey("test chuanglan get pid", t, func() {
  25. pID := cl.GetPid()
  26. So(pID, ShouldEqual, model.ProviderChuangLan)
  27. })
  28. }
  29. func TestSendSms(t *testing.T) {
  30. Convey("test chuanglan send sms", t, func() {
  31. sendLog.Mobile = ""
  32. msgid, err := cl.SendSms(context.TODO(), sendLog)
  33. So(err, ShouldBeNil)
  34. t.Logf("msgid(%s)", msgid)
  35. })
  36. }
  37. func TestSendActSms(t *testing.T) {
  38. Convey("test ChuangLan SendActSms", t, func() {
  39. sendLog.Mobile = ""
  40. msgid, err := cl.SendActSms(context.TODO(), sendLog)
  41. So(err, ShouldBeNil)
  42. t.Logf("msgid(%s)", msgid)
  43. })
  44. }
  45. func TestSendBatchActSms(t *testing.T) {
  46. Convey("test ChuangLan sendBatchActSms", t, func() {
  47. sendLog.Mobile = "" // 187****3870,189****1728
  48. msgid, err := cl.SendBatchActSms(context.TODO(), sendLog)
  49. So(err, ShouldBeNil)
  50. t.Logf("msgid(%s)", msgid)
  51. })
  52. }
  53. func TestSendInternationalSms(t *testing.T) {
  54. Convey("test ChuangLan SendInternationalSms", t, func() {
  55. sendLog.Mobile = "" // 5344295506
  56. sendLog.Country = "1"
  57. msgid, err := cl.SendInternationalSms(context.TODO(), sendLog)
  58. So(err, ShouldBeNil)
  59. t.Logf("msgid(%s)", msgid)
  60. })
  61. }