dao_test.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. package tab
  2. import (
  3. "context"
  4. "flag"
  5. "path/filepath"
  6. "reflect"
  7. "testing"
  8. "go-common/app/interface/main/app-card/model/card/operate"
  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_Menus(t *testing.T) {
  41. type args struct {
  42. c context.Context
  43. }
  44. tests := []struct {
  45. name string
  46. args args
  47. wantMenus []*operate.Menu
  48. wantErr bool
  49. }{
  50. // TODO: Add test cases.
  51. }
  52. for _, tt := range tests {
  53. t.Run(tt.name, func(t *testing.T) {
  54. gotMenus, err := d.Menus(tt.args.c)
  55. if (err != nil) != tt.wantErr {
  56. t.Errorf("Dao.Menus() error = %v, wantErr %v", err, tt.wantErr)
  57. return
  58. }
  59. if !reflect.DeepEqual(gotMenus, tt.wantMenus) {
  60. t.Errorf("Dao.Menus() = %v, want %v", gotMenus, tt.wantMenus)
  61. }
  62. })
  63. }
  64. }
  65. func TestDao_Actives(t *testing.T) {
  66. type args struct {
  67. c context.Context
  68. }
  69. tests := []struct {
  70. name string
  71. args args
  72. wantAcs []*operate.Active
  73. wantErr error
  74. }{}
  75. for _, tt := range tests {
  76. Convey(tt.name, t, func() {
  77. gotAcs, err := d.Actives(tt.args.c)
  78. So(err, ShouldEqual, tt.wantErr)
  79. So(gotAcs, ShouldResemble, tt.wantAcs)
  80. })
  81. }
  82. }