upload_test.go 575 B

1234567891011121314151617181920212223242526
  1. package dao
  2. import (
  3. "bytes"
  4. "context"
  5. "testing"
  6. . "github.com/smartystreets/goconvey/convey"
  7. )
  8. func Test_UploadSql(t *testing.T) {
  9. Convey("upload picture or log file to bfs", t, WithMysql(func(d *Dao) {
  10. var (
  11. fileName = "bilibili.png"
  12. fileType = "png"
  13. expire int64 = 1
  14. bt = []byte("/9j/4QAo.Reader(bt)YRXhpZgAASUkqAAgAAAAAAAAAAAAAA")
  15. body = bytes.NewReader(bt)
  16. )
  17. _, err := d.Upload(context.Background(), fileName, fileType, expire, body)
  18. if err == errUpload {
  19. err = nil
  20. }
  21. So(err, ShouldBeNil)
  22. }))
  23. }