user_test.go 613 B

12345678910111213141516171819202122232425262728293031323334
  1. package dao
  2. import (
  3. "context"
  4. "flag"
  5. "path/filepath"
  6. "testing"
  7. "go-common/app/job/main/sms/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/sms-job-test.toml")
  14. flag.Set("conf", dir)
  15. flag.Parse()
  16. conf.Init()
  17. d = New(conf.Conf)
  18. f(d)
  19. }
  20. }
  21. func Test_GetUserMobile(t *testing.T) {
  22. Convey("get user mobile", t, WithDao(func(d *Dao) {
  23. mob, err := d.UserMobile(context.TODO(), 27515615)
  24. So(err, ShouldBeNil)
  25. So(mob, ShouldNotBeEmpty)
  26. t.Logf("user(%d) mobile(%v)", 27515615, mob)
  27. }))
  28. }