pendant_test.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. package account
  2. import (
  3. "context"
  4. "flag"
  5. "os"
  6. "testing"
  7. "go-common/app/interface/main/answer/conf"
  8. _ "github.com/go-sql-driver/mysql"
  9. . "github.com/smartystreets/goconvey/convey"
  10. )
  11. var d *Dao
  12. func TestMain(m *testing.M) {
  13. if os.Getenv("DEPLOY_ENV") != "" {
  14. flag.Set("app_id", "main.account-law.answer")
  15. flag.Set("conf_appid", "main.account-law.answer")
  16. flag.Set("conf_token", "ba3ee255695e8d7b46782268ddc9c8a3")
  17. flag.Set("tree_id", "25260")
  18. flag.Set("conf_version", "docker-1")
  19. flag.Set("deploy_env", "uat")
  20. flag.Set("conf_env", "10")
  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. } else {
  26. flag.Set("conf", "../../cmd/answer-test.toml")
  27. }
  28. flag.Parse()
  29. if err := conf.Init(); err != nil {
  30. panic(err)
  31. }
  32. d = New(conf.Conf)
  33. os.Exit(m.Run())
  34. }
  35. // Test_BeFormal .
  36. func Test_BeFormal(t *testing.T) {
  37. Convey("Test_BeFormal", t, func() {
  38. var (
  39. c = context.Background()
  40. mid = int64(100000245)
  41. )
  42. d.BeFormal(c, mid, "127.0.0.1")
  43. })
  44. }
  45. // Test_GivePendant .
  46. func Test_GivePendant(t *testing.T) {
  47. Convey("Test_GivePendant", t, func() {
  48. err := d.GivePendant(context.Background(), 21432418, 1, 1, "127.0.0.1")
  49. So(err, ShouldBeNil)
  50. })
  51. }
  52. // go test -test.v -test.run TestDaoExtraIds
  53. func Test_ExtraIds(t *testing.T) {
  54. Convey("Test_GivePendant", t, func() {
  55. var (
  56. err error
  57. c = context.Background()
  58. mid = int64(100000245)
  59. ds, ps []int64
  60. )
  61. ds, ps, err = d.ExtraIds(c, mid, "127.0.0.1")
  62. So(err, ShouldBeNil)
  63. So(ds, ShouldNotBeNil)
  64. So(ps, ShouldNotBeNil)
  65. })
  66. }