dao_test.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. package dm
  2. import (
  3. "context"
  4. "flag"
  5. "go-common/app/interface/main/app-view/conf"
  6. dm "go-common/app/interface/main/dm2/model"
  7. "path/filepath"
  8. "reflect"
  9. "testing"
  10. "time"
  11. . "github.com/smartystreets/goconvey/convey"
  12. )
  13. var d *Dao
  14. func init() {
  15. dir, _ := filepath.Abs("../../cmd/app-view-test.toml")
  16. flag.Set("conf", dir)
  17. conf.Init()
  18. d = New(conf.Conf)
  19. time.Sleep(time.Second)
  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_SubjectInfos(t *testing.T) {
  41. type args struct {
  42. c context.Context
  43. typ int32
  44. plat int8
  45. oids []int64
  46. }
  47. tests := []struct {
  48. name string
  49. args args
  50. wantRes map[int64]*dm.SubjectInfo
  51. wantErr error
  52. }{
  53. {
  54. "normal",
  55. args{
  56. context.TODO(),
  57. 1,
  58. 1,
  59. []int64{12412},
  60. },
  61. map[int64]*dm.SubjectInfo{},
  62. nil,
  63. },
  64. }
  65. for _, tt := range tests {
  66. Convey(tt.name, t, func() {
  67. gotRes, err := d.SubjectInfos(tt.args.c, tt.args.typ, tt.args.plat, tt.args.oids...)
  68. So(err, ShouldEqual, tt.wantErr)
  69. So(gotRes, ShouldResemble, tt.wantRes)
  70. })
  71. }
  72. }