dao_test.go 1017 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package ticket
  2. import (
  3. "context"
  4. "flag"
  5. "fmt"
  6. "os"
  7. "testing"
  8. "go-common/app/interface/main/app-interface/conf"
  9. "github.com/smartystreets/goconvey/convey"
  10. )
  11. var (
  12. d *Dao
  13. )
  14. func TestMain(m *testing.M) {
  15. if os.Getenv("DEPLOY_ENV") != "" {
  16. flag.Set("app_id", "main.app-svr.app-interface")
  17. flag.Set("conf_token", "1mWvdEwZHmCYGoXJCVIdszBOPVdtpXb3")
  18. flag.Set("tree_id", "2688")
  19. flag.Set("conf_version", "docker-1")
  20. flag.Set("deploy_env", "uat")
  21. flag.Set("conf_host", "config.bilibili.co")
  22. flag.Set("conf_path", "/tmp")
  23. flag.Set("region", "sh")
  24. flag.Set("zone", "sh001")
  25. }
  26. flag.Parse()
  27. if err := conf.Init(); err != nil {
  28. panic(err)
  29. }
  30. d = New(conf.Conf)
  31. m.Run()
  32. os.Exit(0)
  33. }
  34. func TestFavCount(t *testing.T) {
  35. var (
  36. c = context.TODO()
  37. mid = int64(27515233)
  38. )
  39. convey.Convey("Ping", t, func(ctx convey.C) {
  40. count, err := d.FavCount(c, mid)
  41. fmt.Printf("%d", count)
  42. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  43. ctx.So(err, convey.ShouldBeNil)
  44. })
  45. })
  46. }