dao_test.go 659 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package upper
  2. import (
  3. "context"
  4. "flag"
  5. "fmt"
  6. "path/filepath"
  7. "testing"
  8. "go-common/app/interface/main/tv/conf"
  9. "encoding/json"
  10. . "github.com/smartystreets/goconvey/convey"
  11. )
  12. var (
  13. ctx = context.TODO()
  14. d *Dao
  15. )
  16. func WithDao(f func(d *Dao)) func() {
  17. return func() {
  18. dir, _ := filepath.Abs("../../cmd/tv-interface.toml")
  19. flag.Set("conf", dir)
  20. conf.Init()
  21. if d == nil {
  22. d = New(conf.Conf)
  23. }
  24. f(d)
  25. }
  26. }
  27. func TestDao_LoadUpMeta(t *testing.T) {
  28. Convey("TestDao_LoadUpMeta", t, WithDao(func(d *Dao) {
  29. res, err := d.LoadUpMeta(ctx, 27515256)
  30. So(err, ShouldBeNil)
  31. data, _ := json.Marshal(res)
  32. fmt.Println(string(data))
  33. }))
  34. }