service_test.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. package service
  2. import (
  3. "context"
  4. "flag"
  5. "path/filepath"
  6. "testing"
  7. "go-common/app/admin/main/sms/conf"
  8. pb "go-common/app/service/main/sms/api"
  9. . "github.com/smartystreets/goconvey/convey"
  10. )
  11. var s *Service
  12. func init() {
  13. dir, _ := filepath.Abs("../cmd/sms-admin-test.toml")
  14. flag.Set("conf", dir)
  15. if err := conf.Init(); err != nil {
  16. panic(err)
  17. }
  18. s = New(conf.Conf)
  19. }
  20. func TestAddTemplate(t *testing.T) {
  21. Convey("add tpl", t, func() {
  22. req := &pb.AddTemplateReq{
  23. Tcode: "test",
  24. Template: "test",
  25. Stype: 2,
  26. Submitter: "wj",
  27. }
  28. _, err := s.AddTemplate(context.TODO(), req)
  29. t.Log(err)
  30. })
  31. }
  32. func TestUpdateTemplate(t *testing.T) {
  33. Convey("update tpl", t, func() {
  34. req := &pb.UpdateTemplateReq{
  35. Tcode: "test",
  36. Template: "test",
  37. Stype: 2,
  38. Status: 1,
  39. Submitter: "wj",
  40. }
  41. _, err := s.UpdateTemplate(context.TODO(), req)
  42. So(err, ShouldNotBeNil)
  43. })
  44. }
  45. func TestTemplateList(t *testing.T) {
  46. Convey("tpl list", t, func() {
  47. req := &pb.TemplateListReq{Pn: 1, Ps: 10}
  48. res, err := s.TemplateList(context.TODO(), req)
  49. So(err, ShouldBeNil)
  50. So(res.Total, ShouldBeGreaterThan, 0)
  51. So(res.List, ShouldNotBeEmpty)
  52. })
  53. }