abtest_test.go 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package abtest
  2. import (
  3. "context"
  4. "flag"
  5. "path/filepath"
  6. "testing"
  7. "time"
  8. "go-common/app/interface/main/app-resource/conf"
  9. . "github.com/smartystreets/goconvey/convey"
  10. )
  11. var (
  12. d *Dao
  13. )
  14. func ctx() context.Context {
  15. return context.Background()
  16. }
  17. func init() {
  18. dir, _ := filepath.Abs("../../cmd/app-resource-test.toml")
  19. flag.Set("conf", dir)
  20. conf.Init()
  21. d = New(conf.Conf)
  22. time.Sleep(time.Second)
  23. }
  24. func TestExperimentLimit(t *testing.T) {
  25. Convey("get ExperimentLimit all", t, func() {
  26. res, err := d.ExperimentLimit(ctx())
  27. So(err, ShouldBeNil)
  28. So(res, ShouldNotBeEmpty)
  29. })
  30. }
  31. func TestExperimentByIDs(t *testing.T) {
  32. Convey("get ExperimentByIDs all", t, func() {
  33. res, err := d.ExperimentByIDs(ctx(), []int64{1})
  34. So(err, ShouldBeNil)
  35. So(res, ShouldNotBeEmpty)
  36. })
  37. }
  38. func TestAbServer(t *testing.T) {
  39. Convey("TestAbServer", t, func() {
  40. res, err := d.AbServer(context.TODO(),
  41. "9902822F-DDD1-47BC-A08F-19F746C9CB8459220infoc",
  42. "phone",
  43. "iphone",
  44. "",
  45. 6720,
  46. 1,
  47. )
  48. Println(string(res), err)
  49. })
  50. }