document_test.go 839 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package dao
  2. import (
  3. "context"
  4. "flag"
  5. "path/filepath"
  6. "testing"
  7. "go-common/app/interface/main/kvo/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-interface-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_Document(t *testing.T) {
  23. Convey("test document", t, WithDao(func(d *Dao) {
  24. checkSum := int64(11111)
  25. data, err := d.Document(context.TODO(), checkSum)
  26. So(err, ShouldBeNil)
  27. Printf("%+v", data)
  28. }))
  29. }
  30. func TestDao_UserConf(t *testing.T) {
  31. Convey("test document", t, WithDao(func(d *Dao) {
  32. mid := int64(11111)
  33. moduleKey := 1
  34. data, err := d.UserConf(context.TODO(), mid, moduleKey)
  35. So(err, ShouldBeNil)
  36. Printf("%+v", data)
  37. }))
  38. }