bfs_test.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestDaoUpload(t *testing.T) {
  8. convey.Convey("Upload", t, func(ctx convey.C) {
  9. var (
  10. c = context.Background()
  11. fileName = "123"
  12. fileType = "image/png"
  13. data = []byte("1231")
  14. bfs = d.c.Bfs
  15. )
  16. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  17. location, err := d.Upload(c, fileName, fileType, data, bfs)
  18. ctx.Convey("Then err should be nil.location should not be nil.", func(ctx convey.C) {
  19. ctx.So(err, convey.ShouldBeNil)
  20. ctx.So(location, convey.ShouldNotBeNil)
  21. })
  22. })
  23. })
  24. }
  25. func TestDaoauthorize(t *testing.T) {
  26. convey.Convey("authorize", t, func(ctx convey.C) {
  27. var (
  28. key = ""
  29. secret = ""
  30. method = ""
  31. bucket = ""
  32. file = ""
  33. expire = int64(0)
  34. )
  35. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  36. authorization := authorize(key, secret, method, bucket, file, expire)
  37. ctx.Convey("Then authorization should not be nil.", func(ctx convey.C) {
  38. ctx.So(authorization, convey.ShouldNotBeNil)
  39. })
  40. })
  41. })
  42. }