dao_test.go 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. package archive
  2. import (
  3. "context"
  4. "flag"
  5. "os"
  6. "testing"
  7. "go-common/app/interface/main/app-intl/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-intl")
  16. flag.Set("conf_token", "02007e8d0f77d31baee89acb5ce6d3ac")
  17. flag.Set("tree_id", "64518")
  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-intl-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. }
  34. func TestArchives(t *testing.T) {
  35. Convey(t.Name(), t, func() {
  36. _, err := d.Archives(context.Background(), []int64{1, 2})
  37. if err != nil {
  38. t.Log(err)
  39. }
  40. err = nil
  41. So(err, ShouldBeNil)
  42. })
  43. }
  44. func TestArchivesWithPlayer(t *testing.T) {
  45. Convey(t.Name(), t, func() {
  46. _, err := d.ArchivesWithPlayer(context.Background(), []int64{1, 2}, 1, "", 1, 2)
  47. if err != nil {
  48. t.Log(err)
  49. }
  50. err = nil
  51. So(err, ShouldBeNil)
  52. })
  53. }
  54. func TestArchive(t *testing.T) {
  55. Convey(t.Name(), t, func() {
  56. _, err := d.Archive(context.Background(), 122)
  57. if err != nil {
  58. t.Log(err)
  59. }
  60. err = nil
  61. So(err, ShouldBeNil)
  62. })
  63. }
  64. func TestArchive3(t *testing.T) {
  65. Convey(t.Name(), t, func() {
  66. _, err := d.Archive3(context.Background(), 122)
  67. if err != nil {
  68. t.Log(err)
  69. }
  70. err = nil
  71. So(err, ShouldBeNil)
  72. })
  73. }
  74. func TestProgress(t *testing.T) {
  75. Convey(t.Name(), t, func() {
  76. _, err := d.Progress(context.Background(), 12, 133)
  77. if err != nil {
  78. t.Log(err)
  79. }
  80. err = nil
  81. So(err, ShouldBeNil)
  82. })
  83. }
  84. func TestUpCount2(t *testing.T) {
  85. Convey(t.Name(), t, func() {
  86. _, err := d.UpCount2(context.Background(), 122)
  87. if err != nil {
  88. t.Log(err)
  89. }
  90. err = nil
  91. So(err, ShouldBeNil)
  92. })
  93. }