dynamic_test.go 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. package external
  2. import (
  3. "context"
  4. "encoding/json"
  5. "flag"
  6. "path/filepath"
  7. "reflect"
  8. "testing"
  9. "go-common/app/interface/main/app-feed/conf"
  10. . "github.com/smartystreets/goconvey/convey"
  11. )
  12. var (
  13. s *Service
  14. )
  15. func init() {
  16. dir, _ := filepath.Abs("../../cmd/app-feed-test.toml")
  17. flag.Set("conf", dir)
  18. conf.Init()
  19. s = New(conf.Conf)
  20. }
  21. func TestService_DynamicNew(t *testing.T) {
  22. type args struct {
  23. c context.Context
  24. params string
  25. }
  26. tests := []struct {
  27. name string
  28. args args
  29. wantRes json.RawMessage
  30. wantErr error
  31. }{
  32. // TODO: Add test cases.
  33. }
  34. for _, tt := range tests {
  35. Convey(tt.name, t, func() {
  36. gotRes, err := s.DynamicNew(tt.args.c, tt.args.params)
  37. So(gotRes, ShouldEqual, tt.wantRes)
  38. So(err, ShouldEqual, tt.wantErr)
  39. })
  40. }
  41. }
  42. func TestService_DynamicCount(t *testing.T) {
  43. type args struct {
  44. c context.Context
  45. params string
  46. }
  47. tests := []struct {
  48. name string
  49. s *Service
  50. args args
  51. wantRes json.RawMessage
  52. wantErr bool
  53. }{
  54. // TODO: Add test cases.
  55. }
  56. for _, tt := range tests {
  57. t.Run(tt.name, func(t *testing.T) {
  58. gotRes, err := tt.s.DynamicCount(tt.args.c, tt.args.params)
  59. if (err != nil) != tt.wantErr {
  60. t.Errorf("Service.DynamicCount() error = %v, wantErr %v", err, tt.wantErr)
  61. return
  62. }
  63. if !reflect.DeepEqual(gotRes, tt.wantRes) {
  64. t.Errorf("Service.DynamicCount() = %v, want %v", gotRes, tt.wantRes)
  65. }
  66. })
  67. }
  68. }
  69. func TestService_DynamicHistory(t *testing.T) {
  70. type args struct {
  71. c context.Context
  72. params string
  73. }
  74. tests := []struct {
  75. name string
  76. s *Service
  77. args args
  78. wantRes json.RawMessage
  79. wantErr bool
  80. }{
  81. // TODO: Add test cases.
  82. }
  83. for _, tt := range tests {
  84. t.Run(tt.name, func(t *testing.T) {
  85. gotRes, err := tt.s.DynamicHistory(tt.args.c, tt.args.params)
  86. if (err != nil) != tt.wantErr {
  87. t.Errorf("Service.DynamicHistory() error = %v, wantErr %v", err, tt.wantErr)
  88. return
  89. }
  90. if !reflect.DeepEqual(gotRes, tt.wantRes) {
  91. t.Errorf("Service.DynamicHistory() = %v, want %v", gotRes, tt.wantRes)
  92. }
  93. })
  94. }
  95. }