dao_test.go 1012 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package dao
  2. import (
  3. "io/ioutil"
  4. "net/http"
  5. "os"
  6. "sync"
  7. "testing"
  8. "time"
  9. "go-common/app/interface/main/upload/conf"
  10. xtime "go-common/library/time"
  11. )
  12. var (
  13. b *Bfs
  14. testData []byte
  15. once sync.Once
  16. )
  17. func TestMain(m *testing.M) {
  18. initData()
  19. once.Do(initBFS)
  20. os.Exit(m.Run())
  21. }
  22. func initBFS() {
  23. b = NewBfs(&conf.Config{
  24. Bfs: &conf.Bfs{
  25. BfsURL: "uat-bfs.bilibili.co",
  26. WaterMarkURL: "http://172.18.33.121:8090/imageserver/watermark/gen",
  27. ImageGenURL: "http://172.18.33.121:8090/imageserver/image/gen",
  28. TimeOut: xtime.Duration(time.Second * 5),
  29. WmTimeOut: xtime.Duration(time.Second * 5),
  30. ImageGenTimeOut: xtime.Duration(time.Second * 5),
  31. },
  32. })
  33. }
  34. func initData() {
  35. client := &http.Client{}
  36. resp, err := client.Get("http://uat-i0.hdslb.com/bfs/archive/fc7cd08beb29f93c596426557cf1aa11a08e9730.jpg")
  37. if err != nil {
  38. panic(err)
  39. }
  40. defer resp.Body.Close()
  41. if testData, err = ioutil.ReadAll(resp.Body); err != nil {
  42. panic(err)
  43. }
  44. }