dao_test.go 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. package archive
  2. import (
  3. "context"
  4. "flag"
  5. "os"
  6. "testing"
  7. "go-common/app/interface/main/app-interface/conf"
  8. "github.com/smartystreets/goconvey/convey"
  9. )
  10. var (
  11. d *Dao
  12. )
  13. func TestMain(m *testing.M) {
  14. if os.Getenv("DEPLOY_ENV") != "" {
  15. flag.Set("app_id", "main.app-svr.app-interface")
  16. flag.Set("conf_token", "1mWvdEwZHmCYGoXJCVIdszBOPVdtpXb3")
  17. flag.Set("tree_id", "2688")
  18. flag.Set("conf_version", "docker-1")
  19. flag.Set("deploy_env", "uat")
  20. flag.Set("conf_host", "config.bilibili.co")
  21. flag.Set("conf_path", "/tmp")
  22. flag.Set("region", "sh")
  23. flag.Set("zone", "sh001")
  24. } else {
  25. flag.Set("conf", "../../cmd/app-interface-test.toml")
  26. }
  27. flag.Parse()
  28. if err := conf.Init(); err != nil {
  29. panic(err)
  30. }
  31. d = New(conf.Conf)
  32. os.Exit(m.Run())
  33. // time.Sleep(time.Second)
  34. }
  35. func TestUpArcs3(t *testing.T) {
  36. var (
  37. c = context.TODO()
  38. mid = int64(1)
  39. pn = 1
  40. ps = 5
  41. )
  42. convey.Convey("UpArcs3", t, func(ctx convey.C) {
  43. _, err := d.UpArcs3(c, mid, pn, ps)
  44. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  45. ctx.So(err, convey.ShouldBeNil)
  46. })
  47. })
  48. }
  49. func TestUpCount2(t *testing.T) {
  50. var (
  51. c = context.TODO()
  52. mid = int64(1)
  53. )
  54. convey.Convey("UpCount2", t, func(ctx convey.C) {
  55. _, err := d.UpCount2(c, mid)
  56. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  57. ctx.So(err, convey.ShouldBeNil)
  58. })
  59. })
  60. }
  61. func TestArchive(t *testing.T) {
  62. var (
  63. c = context.TODO()
  64. aids = []int64{1}
  65. )
  66. convey.Convey("Archives", t, func(ctx convey.C) {
  67. _, err := d.Archives(c, aids)
  68. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  69. ctx.So(err, convey.ShouldBeNil)
  70. })
  71. })
  72. }
  73. func TestArchive2(t *testing.T) {
  74. var (
  75. c = context.TODO()
  76. aids = []int64{1}
  77. )
  78. convey.Convey("Archives2", t, func(ctx convey.C) {
  79. _, err := d.Archives2(c, aids)
  80. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  81. ctx.So(err, convey.ShouldBeNil)
  82. })
  83. })
  84. }