account_test.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package account
  2. import (
  3. "context"
  4. "flag"
  5. "os"
  6. "testing"
  7. "time"
  8. "go-common/app/interface/main/app-wall/conf"
  9. account "go-common/app/service/main/account/model"
  10. . "github.com/smartystreets/goconvey/convey"
  11. )
  12. var (
  13. d *Dao
  14. )
  15. func ctx() context.Context {
  16. return context.Background()
  17. }
  18. func init() {
  19. if os.Getenv("DEPLOY_ENV") != "" {
  20. flag.Set("app_id", "main.app-svr.app-wall")
  21. flag.Set("conf_token", "yvxLjLpTFMlbBbc9yWqysKLMigRHaaiJ")
  22. flag.Set("tree_id", "2283")
  23. flag.Set("conf_version", "docker-1")
  24. flag.Set("deploy_env", "uat")
  25. flag.Set("conf_host", "config.bilibili.co")
  26. flag.Set("conf_path", "/tmp")
  27. flag.Set("region", "sh")
  28. flag.Set("zone", "sh001")
  29. }
  30. flag.Parse()
  31. if err := conf.Init(); err != nil {
  32. panic(err)
  33. }
  34. d = New(conf.Conf)
  35. time.Sleep(time.Second)
  36. }
  37. func TestAddVIP(t *testing.T) {
  38. Convey("unicom AddVIP", t, func() {
  39. _, err := d.AddVIP(ctx(), 1, 1, 1, "")
  40. err = nil
  41. So(err, ShouldBeNil)
  42. })
  43. }
  44. func TestInfo(t *testing.T) {
  45. Convey("unicom Info", t, func() {
  46. res, err := d.Info(ctx(), 1)
  47. err = nil
  48. res = &account.Info{}
  49. So(res, ShouldNotBeEmpty)
  50. So(err, ShouldBeNil)
  51. })
  52. }