service_test.go 964 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. package service
  2. import (
  3. "context"
  4. "flag"
  5. "fmt"
  6. "path/filepath"
  7. "testing"
  8. "time"
  9. "go-common/app/interface/main/credit/conf"
  10. . "github.com/smartystreets/goconvey/convey"
  11. )
  12. var (
  13. s *Service
  14. )
  15. // func CleanCache() {
  16. // c := context.TODO()
  17. // pool := redis.NewPool(conf.Conf.Redis.Config)
  18. // pool.Get(c).Do("FLUSHDB")
  19. // }
  20. func init() {
  21. dir, _ := filepath.Abs("../cmd/convey-test.toml")
  22. flag.Set("conf", dir)
  23. conf.Init()
  24. s = New(conf.Conf)
  25. time.Sleep(time.Second)
  26. }
  27. // func WithService(f func(s *Service)) func() {
  28. // return func() {
  29. // Reset(func() { CleanCache() })
  30. // f(s)
  31. // }
  32. // }
  33. func Test_LoadConf(t *testing.T) {
  34. Convey("should return err be nil", t, func() {
  35. s.loadConf()
  36. fmt.Printf("%+v", s.c.Judge)
  37. })
  38. }
  39. func Test_BatchBLKCases(t *testing.T) {
  40. ids := []int64{111, 22, 333}
  41. Convey("return someting", t, func() {
  42. cas, err := s.BatchBLKCases(context.TODO(), ids)
  43. So(err, ShouldBeNil)
  44. So(cas, ShouldNotBeNil)
  45. })
  46. }