dao_test.go 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. package act
  2. import (
  3. "context"
  4. "flag"
  5. "fmt"
  6. "os"
  7. "testing"
  8. "go-common/app/interface/main/app-view/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-view")
  17. flag.Set("conf_token", "3a4CNLBhdFbRQPs7B4QftGvXHtJo92xw")
  18. flag.Set("tree_id", "4575")
  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 TestInfo(t *testing.T) {
  35. var (
  36. c = context.TODO()
  37. actID = int64(1)
  38. randomCnt = int64(10)
  39. )
  40. convey.Convey("Info", t, func(ctx convey.C) {
  41. _, _, err := d.Info(c, actID, randomCnt)
  42. ctx.Convey("Then err should not be nil.", func(ctx convey.C) {
  43. ctx.So(err, convey.ShouldNotBeNil)
  44. })
  45. })
  46. }
  47. func TestLeftLotteryTimes(t *testing.T) {
  48. var (
  49. c = context.TODO()
  50. actID = int64(1)
  51. mid = int64(1)
  52. )
  53. convey.Convey("LeftLotteryTimes", t, func(ctx convey.C) {
  54. _, err := d.LeftLotteryTimes(c, actID, mid)
  55. ctx.Convey("Then err should not be nil.", func(ctx convey.C) {
  56. ctx.So(err, convey.ShouldNotBeNil)
  57. })
  58. })
  59. }
  60. func TestActProtocol(t *testing.T) {
  61. var (
  62. c = context.TODO()
  63. messionID = int64(10338)
  64. )
  65. convey.Convey("ActProtocol", t, func(ctx convey.C) {
  66. act, err := d.ActProtocol(c, messionID)
  67. fmt.Printf("=====%#v======", act)
  68. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  69. ctx.So(err, convey.ShouldBeNil)
  70. })
  71. })
  72. }