dao_test.go 572 B

12345678910111213141516171819202122232425262728293031323334
  1. package operation
  2. import (
  3. "context"
  4. "flag"
  5. "path/filepath"
  6. "testing"
  7. "go-common/app/interface/main/web-show/conf"
  8. . "github.com/smartystreets/goconvey/convey"
  9. )
  10. var d *Dao
  11. func WithDao(f func(d *Dao)) func() {
  12. return func() {
  13. dir, _ := filepath.Abs("../cmd/web-show-test.toml")
  14. flag.Set("conf", dir)
  15. conf.Init()
  16. if d == nil {
  17. d = New(conf.Conf)
  18. }
  19. f(d)
  20. }
  21. }
  22. func TestDao_Operation(t *testing.T) {
  23. Convey("test operation", t, WithDao(func(d *Dao) {
  24. data, err := d.Operation(context.TODO())
  25. So(err, ShouldBeNil)
  26. Printf("%+v", data)
  27. }))
  28. }