dao_test.go 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. package dynamic
  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. d *Dao
  14. )
  15. func init() {
  16. dir, _ := filepath.Abs("../../cmd/app-feed-test.toml")
  17. flag.Set("conf", dir)
  18. conf.Init()
  19. d = New(conf.Conf)
  20. }
  21. func TestNew(t *testing.T) {
  22. type args struct {
  23. c *conf.Config
  24. }
  25. tests := []struct {
  26. name string
  27. args args
  28. wantD *Dao
  29. }{
  30. // TODO: Add test cases.
  31. }
  32. for _, tt := range tests {
  33. t.Run(tt.name, func(t *testing.T) {
  34. if gotD := New(tt.args.c); !reflect.DeepEqual(gotD, tt.wantD) {
  35. t.Errorf("New() = %v, want %v", gotD, tt.wantD)
  36. }
  37. })
  38. }
  39. }
  40. func TestDao_dynamicSrv(t *testing.T) {
  41. type args struct {
  42. c context.Context
  43. reqPath string
  44. params string
  45. }
  46. tests := []struct {
  47. name string
  48. args args
  49. wantRes json.RawMessage
  50. wantErr error
  51. }{
  52. // TODO: Add test cases.
  53. }
  54. for _, tt := range tests {
  55. t.Run(tt.name, func(t *testing.T) {
  56. gotRes, err := d.dynamicSrv(tt.args.c, tt.args.reqPath, tt.args.params)
  57. So(gotRes, ShouldEqual, tt.wantRes)
  58. So(err, ShouldEqual, tt.wantErr)
  59. })
  60. }
  61. }
  62. func TestDao_DynamicHistory(t *testing.T) {
  63. type args struct {
  64. c context.Context
  65. params string
  66. }
  67. tests := []struct {
  68. name string
  69. d *Dao
  70. args args
  71. wantRes json.RawMessage
  72. wantErr bool
  73. }{
  74. // TODO: Add test cases.
  75. }
  76. for _, tt := range tests {
  77. t.Run(tt.name, func(t *testing.T) {
  78. gotRes, err := tt.d.DynamicHistory(tt.args.c, tt.args.params)
  79. if (err != nil) != tt.wantErr {
  80. t.Errorf("Dao.DynamicHistory() error = %v, wantErr %v", err, tt.wantErr)
  81. return
  82. }
  83. if !reflect.DeepEqual(gotRes, tt.wantRes) {
  84. t.Errorf("Dao.DynamicHistory() = %v, want %v", gotRes, tt.wantRes)
  85. }
  86. })
  87. }
  88. }
  89. func TestDao_DynamicCount(t *testing.T) {
  90. type args struct {
  91. c context.Context
  92. params string
  93. }
  94. tests := []struct {
  95. name string
  96. d *Dao
  97. args args
  98. wantRes json.RawMessage
  99. wantErr bool
  100. }{
  101. // TODO: Add test cases.
  102. }
  103. for _, tt := range tests {
  104. t.Run(tt.name, func(t *testing.T) {
  105. gotRes, err := tt.d.DynamicCount(tt.args.c, tt.args.params)
  106. if (err != nil) != tt.wantErr {
  107. t.Errorf("Dao.DynamicCount() error = %v, wantErr %v", err, tt.wantErr)
  108. return
  109. }
  110. if !reflect.DeepEqual(gotRes, tt.wantRes) {
  111. t.Errorf("Dao.DynamicCount() = %v, want %v", gotRes, tt.wantRes)
  112. }
  113. })
  114. }
  115. }
  116. func TestDao_DynamicNew(t *testing.T) {
  117. type args struct {
  118. c context.Context
  119. params string
  120. }
  121. tests := []struct {
  122. name string
  123. d *Dao
  124. args args
  125. wantRes json.RawMessage
  126. wantErr bool
  127. }{
  128. // TODO: Add test cases.
  129. }
  130. for _, tt := range tests {
  131. t.Run(tt.name, func(t *testing.T) {
  132. gotRes, err := tt.d.DynamicNew(tt.args.c, tt.args.params)
  133. if (err != nil) != tt.wantErr {
  134. t.Errorf("Dao.DynamicNew() error = %v, wantErr %v", err, tt.wantErr)
  135. return
  136. }
  137. if !reflect.DeepEqual(gotRes, tt.wantRes) {
  138. t.Errorf("Dao.DynamicNew() = %v, want %v", gotRes, tt.wantRes)
  139. }
  140. })
  141. }
  142. }