audit_test.go 1.7 KB

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