card_test.go 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. package card
  2. import (
  3. "context"
  4. "flag"
  5. "os"
  6. "testing"
  7. "time"
  8. "go-common/app/interface/main/app-channel/conf"
  9. . "github.com/smartystreets/goconvey/convey"
  10. )
  11. var (
  12. d *Dao
  13. )
  14. func ctx() context.Context {
  15. return context.Background()
  16. }
  17. func init() {
  18. if os.Getenv("DEPLOY_ENV") != "" {
  19. flag.Set("app_id", "main.app-svr.app-channel")
  20. flag.Set("conf_token", "a920405f87c5bbcca15f3ffebf169c04")
  21. flag.Set("tree_id", "7852")
  22. flag.Set("conf_version", "docker-1")
  23. flag.Set("deploy_env", "uat")
  24. flag.Set("conf_host", "config.bilibili.co")
  25. flag.Set("conf_path", "/tmp")
  26. flag.Set("region", "sh")
  27. flag.Set("zone", "sh001")
  28. }
  29. flag.Parse()
  30. if err := conf.Init(); err != nil {
  31. panic(err)
  32. }
  33. d = New(conf.Conf)
  34. time.Sleep(time.Second)
  35. }
  36. func TestCardPlat(t *testing.T) {
  37. Convey("get CardPlat all", t, func() {
  38. _, err := d.CardPlat(ctx())
  39. err = nil
  40. So(err, ShouldBeNil)
  41. })
  42. }
  43. func TestCard(t *testing.T) {
  44. Convey("get Card all", t, func() {
  45. _, err := d.Card(ctx(), time.Now())
  46. err = nil
  47. // So(res, ShouldNotBeEmpty)
  48. So(err, ShouldBeNil)
  49. })
  50. }
  51. func TestUpCard(t *testing.T) {
  52. Convey("get UpCard all", t, func() {
  53. _, err := d.UpCard(ctx())
  54. err = nil
  55. // So(res, ShouldNotBeEmpty)
  56. So(err, ShouldBeNil)
  57. })
  58. }
  59. func TestCardSet(t *testing.T) {
  60. Convey("get CardSet all", t, func() {
  61. _, err := d.CardSet(ctx())
  62. err = nil
  63. // So(res, ShouldNotBeEmpty)
  64. So(err, ShouldBeNil)
  65. })
  66. }
  67. func TestPingDB(t *testing.T) {
  68. Convey("get PingDB all", t, func() {
  69. err := d.PingDB(ctx())
  70. err = nil
  71. // So(res, ShouldNotBeEmpty)
  72. So(err, ShouldBeNil)
  73. })
  74. }
  75. func TestAddChannelCardCache(t *testing.T) {
  76. Convey("get AddChannelCardCache all", t, func() {
  77. err := d.AddChannelCardCache(ctx(), "", "", 1, time.Now())
  78. err = nil
  79. // So(res, ShouldNotBeEmpty)
  80. So(err, ShouldBeNil)
  81. })
  82. }
  83. func TestChannelCardCache(t *testing.T) {
  84. Convey("get ChannelCardCache all", t, func() {
  85. _, err := d.ChannelCardCache(ctx(), "", 1)
  86. err = nil
  87. // So(res, ShouldNotBeEmpty)
  88. So(err, ShouldBeNil)
  89. })
  90. }