region_test.go 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. package region
  2. import (
  3. "context"
  4. "flag"
  5. "path/filepath"
  6. "reflect"
  7. "testing"
  8. "time"
  9. "go-common/app/interface/main/app-feed/conf"
  10. "go-common/app/interface/main/app-feed/model/tag"
  11. . "github.com/smartystreets/goconvey/convey"
  12. )
  13. var (
  14. s *Service
  15. )
  16. func init() {
  17. dir, _ := filepath.Abs("../../cmd/app-feed-test.toml")
  18. flag.Set("conf", dir)
  19. conf.Init()
  20. s = New(conf.Conf)
  21. }
  22. func TestService_HotTags(t *testing.T) {
  23. type args struct {
  24. c context.Context
  25. mid int64
  26. rid int16
  27. ver string
  28. plat int8
  29. now time.Time
  30. }
  31. tests := []struct {
  32. name string
  33. args args
  34. wantHs []*tag.Hot
  35. wantVersion string
  36. wantErr error
  37. }{
  38. // TODO: Add test cases.
  39. }
  40. for _, tt := range tests {
  41. t.Run(tt.name, func(t *testing.T) {
  42. gotHs, gotVersion, err := s.HotTags(tt.args.c, tt.args.mid, tt.args.rid, tt.args.ver, tt.args.plat, tt.args.now)
  43. So(gotHs, ShouldEqual, tt.wantHs)
  44. So(gotVersion, ShouldEqual, tt.wantVersion)
  45. So(err, ShouldEqual, tt.wantErr)
  46. })
  47. }
  48. }
  49. func TestService_SubTags(t *testing.T) {
  50. type args struct {
  51. c context.Context
  52. mid int64
  53. pn int
  54. ps int
  55. }
  56. tests := []struct {
  57. name string
  58. s *Service
  59. args args
  60. wantT *tag.SubTag
  61. }{
  62. // TODO: Add test cases.
  63. }
  64. for _, tt := range tests {
  65. t.Run(tt.name, func(t *testing.T) {
  66. if gotT := tt.s.SubTags(tt.args.c, tt.args.mid, tt.args.pn, tt.args.ps); !reflect.DeepEqual(gotT, tt.wantT) {
  67. t.Errorf("Service.SubTags() = %v, want %v", gotT, tt.wantT)
  68. }
  69. })
  70. }
  71. }
  72. func TestService_AddTag(t *testing.T) {
  73. type args struct {
  74. c context.Context
  75. mid int64
  76. tid int64
  77. now time.Time
  78. }
  79. tests := []struct {
  80. name string
  81. s *Service
  82. args args
  83. wantErr bool
  84. }{
  85. // TODO: Add test cases.
  86. }
  87. for _, tt := range tests {
  88. t.Run(tt.name, func(t *testing.T) {
  89. if err := tt.s.AddTag(tt.args.c, tt.args.mid, tt.args.tid, tt.args.now); (err != nil) != tt.wantErr {
  90. t.Errorf("Service.AddTag() error = %v, wantErr %v", err, tt.wantErr)
  91. }
  92. })
  93. }
  94. }
  95. func TestService_CancelTag(t *testing.T) {
  96. type args struct {
  97. c context.Context
  98. mid int64
  99. tid int64
  100. now time.Time
  101. }
  102. tests := []struct {
  103. name string
  104. s *Service
  105. args args
  106. wantErr bool
  107. }{
  108. // TODO: Add test cases.
  109. }
  110. for _, tt := range tests {
  111. t.Run(tt.name, func(t *testing.T) {
  112. if err := tt.s.CancelTag(tt.args.c, tt.args.mid, tt.args.tid, tt.args.now); (err != nil) != tt.wantErr {
  113. t.Errorf("Service.CancelTag() error = %v, wantErr %v", err, tt.wantErr)
  114. }
  115. })
  116. }
  117. }