dao_test.go 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. package search
  2. import (
  3. "context"
  4. "flag"
  5. "os"
  6. "testing"
  7. "time"
  8. "go-common/app/interface/main/app-intl/conf"
  9. . "github.com/smartystreets/goconvey/convey"
  10. )
  11. var (
  12. d *Dao
  13. )
  14. func TestMain(m *testing.M) {
  15. if os.Getenv("DEPLOY_ENV") != "" {
  16. flag.Set("app_id", "main.app-svr.app-intl")
  17. flag.Set("conf_token", "02007e8d0f77d31baee89acb5ce6d3ac")
  18. flag.Set("tree_id", "64518")
  19. flag.Set("conf_version", "docker-1")
  20. flag.Set("deploy_env", "uat")
  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/app-intl-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. func TestSearch(t *testing.T) {
  36. Convey("get Search", t, func() {
  37. res, _, err := d.Search(context.Background(), 1, 2, "iphone", "phone", "1", "6E657F43-A770-4F7B-A6AE-FDFFCA8ED46216837infoc", "123", "0", "1", "1", "1", "1", 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 8160, 1, 20, time.Now())
  38. if err != nil {
  39. t.Log(err)
  40. }
  41. err = nil
  42. So(err, ShouldBeNil)
  43. So(res, ShouldNotBeEmpty)
  44. })
  45. }
  46. func TestUpper(t *testing.T) {
  47. Convey("get Upper", t, func() {
  48. res, err := d.Upper(context.Background(), 1, "iphone", "phone", "1", "6E657F43-A770-4F7B-A6AE-FDFFCA8ED46216837infoc", "123", "0", "1", 1, 2, 3, 4, 5, 1, 20, time.Now())
  49. if err != nil {
  50. t.Log(err)
  51. }
  52. err = nil
  53. So(err, ShouldBeNil)
  54. So(res, ShouldNotBeEmpty)
  55. })
  56. }
  57. func TestArticleByType(t *testing.T) {
  58. Convey("get ArticleByType", t, func() {
  59. res, err := d.ArticleByType(context.Background(), 1, 12313, "iphone", "phone", "1", "6E657F43-A770-4F7B-A6AE-FDFFCA8ED46216837infoc", "123", "0", "1", "2", int8(1), 1, 8190, 1, 1, 20, time.Now())
  60. if err != nil {
  61. t.Log(err)
  62. }
  63. err = nil
  64. So(err, ShouldBeNil)
  65. So(res, ShouldNotBeEmpty)
  66. })
  67. }
  68. func TestSuggest3(t *testing.T) {
  69. Convey("get Suggest3", t, func() {
  70. res, err := d.Suggest3(context.Background(), 12313, "ios", "6E657F43-A770-4F7B-A6AE-FDFFCA8ED46216837infoc", "123", 8190, 1, "iphone", time.Now())
  71. if err != nil {
  72. t.Log(err)
  73. }
  74. err = nil
  75. So(err, ShouldBeNil)
  76. So(res, ShouldNotBeEmpty)
  77. })
  78. }