dao_test.go 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. package account
  2. import (
  3. "context"
  4. "flag"
  5. "path/filepath"
  6. "testing"
  7. "go-common/library/ecode"
  8. . "github.com/smartystreets/goconvey/convey"
  9. "go-common/app/job/main/up/conf"
  10. )
  11. var (
  12. d *Dao
  13. )
  14. func init() {
  15. dir, _ := filepath.Abs("../../cmd/up-admin.toml")
  16. flag.Set("conf", dir)
  17. conf.Init()
  18. d = New(conf.Conf)
  19. }
  20. func WithDao(f func(d *Dao)) func() {
  21. return func() {
  22. Reset(func() {})
  23. f(d)
  24. }
  25. }
  26. func Test_IdentifyInfo(t *testing.T) {
  27. var (
  28. c = context.Background()
  29. err error
  30. mid = int64(27515256)
  31. ak = "efbf2e093c3c04008acbd9906ba970db"
  32. ck = ""
  33. ip = "127.0.0.1"
  34. )
  35. Convey("IdentifyInfo", t, WithDao(func(d *Dao) {
  36. err = d.IdentifyInfo(c, ak, ck, ip, mid)
  37. So(err, ShouldNotBeNil)
  38. So(err, ShouldEqual, ecode.CreativeAccServiceErr)
  39. }))
  40. }
  41. func Test_GetCachedInfos(t *testing.T) {
  42. var (
  43. c = context.Background()
  44. err error
  45. mids = []int64{1234, 12345}
  46. ip = "127.0.0.1"
  47. )
  48. Convey("GetCachedInfos", t, WithDao(func(d *Dao) {
  49. _, err = d.GetCachedInfos(c, mids, ip)
  50. So(err, ShouldNotBeNil)
  51. }))
  52. }