request_file_test.go 672 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package filesdk
  2. import (
  3. "io/ioutil"
  4. "os"
  5. "testing"
  6. )
  7. func TestMain(m *testing.M) {
  8. i := Config{
  9. Host: "http://127.0.0.1:18199",
  10. }
  11. i.Init()
  12. m.Run()
  13. }
  14. func Test_Persistent_file(t *testing.T) {
  15. var hash = "sss"
  16. if err := GetHandle().HandlePersistent(hash); err != nil {
  17. t.Errorf("GetHandle().HandlePersistent() error %s", err)
  18. return
  19. }
  20. }
  21. func TestConfigHandle_Upload(t *testing.T) {
  22. fileBytes, err := os.Open("logo.png")
  23. if err != nil {
  24. t.Fatal(err)
  25. }
  26. buf, err := ioutil.ReadAll(fileBytes)
  27. if err != nil {
  28. t.Fatal(err)
  29. }
  30. result, err := GetHandle().Upload("test.jpg", "testbucket", nil, buf)
  31. if err != nil {
  32. t.Fatal(err)
  33. }
  34. t.Log(result)
  35. }