upbfs_test.go 972 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package service
  2. import (
  3. "context"
  4. "fmt"
  5. "testing"
  6. "time"
  7. . "github.com/smartystreets/goconvey/convey"
  8. )
  9. var (
  10. c = context.TODO()
  11. now = time.Now().Unix()
  12. )
  13. func TestService_Upload(t *testing.T) {
  14. Convey("Upload should return without err", t, WithService(func(svf *Service) {
  15. // simulate file content
  16. str2 := "Testing File Content"
  17. data2 := []byte(str2)
  18. // upload to bfs
  19. location, err := svf.Upload(c, "tName", "image/png", now, data2)
  20. // testing
  21. So(err, ShouldBeNil)
  22. So(location, ShouldNotBeNil)
  23. fmt.Println(location)
  24. }))
  25. }
  26. func TestService_ParseFile(t *testing.T) {
  27. Convey("ParseFile can get file info", t, WithService(func(svf *Service) {
  28. // simulate file content
  29. str2 := "Testing File Content"
  30. data2 := []byte(str2)
  31. // upload to bfs
  32. fInfo, err := svf.ParseFile(c, data2)
  33. // testing
  34. So(err, ShouldBeNil)
  35. So(fInfo.Size, ShouldBeGreaterThan, 0)
  36. So(fInfo.Type, ShouldNotBeBlank)
  37. So(fInfo.Md5, ShouldNotBeBlank)
  38. }))
  39. }