dao_test.go 737 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package elec
  2. import (
  3. "context"
  4. "flag"
  5. "path/filepath"
  6. "testing"
  7. "time"
  8. "go-common/app/interface/main/app-view/conf"
  9. . "github.com/smartystreets/goconvey/convey"
  10. )
  11. var (
  12. d *Dao
  13. )
  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 ctx() context.Context {
  22. return context.Background()
  23. }
  24. func TestTotalInfo(t *testing.T) {
  25. Convey("get TotalInfo all", t, func() {
  26. res, err := d.TotalInfo(ctx(), 1, 1)
  27. So(err, ShouldBeNil)
  28. So(res, ShouldNotBeEmpty)
  29. })
  30. }
  31. func TestInfo(t *testing.T) {
  32. Convey("get Info all", t, func() {
  33. res, err := d.Info(ctx(), 1, 1)
  34. So(err, ShouldBeNil)
  35. So(res, ShouldNotBeEmpty)
  36. })
  37. }