upbfs_test.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package dao
  2. import (
  3. "context"
  4. "go-common/app/admin/main/creative/conf"
  5. "testing"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDaoUpload(t *testing.T) {
  9. convey.Convey("Upload", t, func(ctx convey.C) {
  10. var (
  11. c = context.Background()
  12. fileName = "filename"
  13. fileType = "png"
  14. timing = int64(1545382342)
  15. data = []byte("iamdata")
  16. bfs = &conf.Bfs{}
  17. )
  18. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  19. bfs = d.c.Bfs
  20. location, err := d.Upload(c, fileName, fileType, timing, data, bfs)
  21. ctx.Convey("Then err should be nil.location should not be nil.", func(ctx convey.C) {
  22. ctx.So(err, convey.ShouldNotBeNil) // http code 401
  23. ctx.So(location, convey.ShouldNotBeNil)
  24. })
  25. })
  26. })
  27. }
  28. func TestDaoauthorize(t *testing.T) {
  29. convey.Convey("authorize", t, func(ctx convey.C) {
  30. var (
  31. key = "8d4e593ba7555502"
  32. secret = "0bdbd4c7caeeddf587c3c4daec0475"
  33. method = "PUT"
  34. bucket = "archive"
  35. file = ""
  36. expire = int64(100)
  37. )
  38. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  39. authorization := authorize(key, secret, method, bucket, file, expire)
  40. ctx.Convey("Then authorization should not be nil.", func(ctx convey.C) {
  41. ctx.So(authorization, convey.ShouldNotBeNil)
  42. })
  43. })
  44. })
  45. }