upload_test.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package bfs
  2. import (
  3. "context"
  4. "testing"
  5. . "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestUpload(t *testing.T) {
  8. Convey("internal upload", t, func() {
  9. b := New(nil)
  10. req := &Request{
  11. Bucket: "b",
  12. ContentType: "application/json",
  13. File: []byte("hello world"),
  14. }
  15. res, err := b.Upload(context.TODO(), req)
  16. So(err, ShouldBeNil)
  17. So(res, ShouldNotBeNil)
  18. t.Logf("%+v", res)
  19. })
  20. }
  21. func TestFilenameUpload(t *testing.T) {
  22. Convey("internal upload by specify filename", t, func() {
  23. b := New(nil)
  24. req := &Request{
  25. Bucket: "b",
  26. Dir: "/test",
  27. Filename: "test.plain",
  28. ContentType: "application/json",
  29. File: []byte("........"),
  30. }
  31. res, err := b.Upload(context.TODO(), req)
  32. So(err, ShouldBeNil)
  33. So(res, ShouldNotBeNil)
  34. t.Logf("%+v", res)
  35. })
  36. }
  37. func TestGenWatermark(t *testing.T) {
  38. Convey("create watermark by key and text", t, func() {
  39. b := New(nil)
  40. location, err := b.GenWatermark(context.TODO(), "c605dd5324f91ea1", "comic", "hello world", true, 2)
  41. So(err, ShouldBeNil)
  42. t.Logf("location:%s", location)
  43. })
  44. }