dao_test.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. package topic
  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 TestTopic(t *testing.T) {
  36. var (
  37. c = context.TODO()
  38. accessKey = ""
  39. actionKey = ""
  40. device = ""
  41. mobiApp = ""
  42. platform = ""
  43. build = 111
  44. ps = 5
  45. pn = 1
  46. mid = int64(1)
  47. )
  48. convey.Convey("Topic", t, func(ctx convey.C) {
  49. _, err := d.Topic(c, accessKey, actionKey, device, mobiApp, platform, build, ps, pn, mid)
  50. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  51. ctx.So(err, convey.ShouldBeNil)
  52. })
  53. })
  54. }
  55. func TestUserFolder(t *testing.T) {
  56. var (
  57. c = context.TODO()
  58. mid = int64(1)
  59. typ = int32(4)
  60. )
  61. convey.Convey("UserFolder", t, func(ctx convey.C) {
  62. _, err := d.UserFolder(c, mid, typ)
  63. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  64. ctx.So(err, convey.ShouldBeNil)
  65. })
  66. })
  67. }