weedcl_test.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package weedcl
  2. import (
  3. "fmt"
  4. "log"
  5. "net/http"
  6. "testing"
  7. )
  8. func Test_assign(t *testing.T) {
  9. c := NewClient("http://192.168.3.14:9333")
  10. fid, url, publicurl, err := c.assign()
  11. fmt.Println(fid, url, publicurl, err)
  12. }
  13. func Test_upload(t *testing.T) {
  14. c := NewClient("http://192.168.3.14:9333")
  15. fid, publicurl, err := c.Upload("/Users/zhp/projects/jy/app.json")
  16. log.Println(fid, publicurl, err)
  17. }
  18. //上传网络资源
  19. func Test_upload2(t *testing.T) {
  20. resp, _ := http.Get("http://fanyi.baidu.com/static/translation/img/header/logo_cbfea26.png")
  21. defer resp.Body.Close()
  22. c := NewClient("http://192.168.3.14:9333")
  23. fid, publicurl, err := c.UploadFromReader("baidu_icon.png", resp.Body)
  24. log.Println(fid, publicurl, err)
  25. }
  26. func Test_delete(t *testing.T) {
  27. c := NewClient("http://192.168.3.14:9333")
  28. err := c.Delete("27,0e6846633a", "192.168.3.14:9888")
  29. log.Println(err)
  30. }
  31. func Test_update(t *testing.T) {
  32. resp, _ := http.Get("http://cdn.chinaz.com/tools/images/public/logos/logo-index.png")
  33. defer resp.Body.Close()
  34. c := NewClient("http://192.168.3.14:9333")
  35. fid, publicurl, err := c.UpdateFromReader("baidu_icon.png", "192.168.3.14:9888", "23,0f970140b1", resp.Body)
  36. log.Println(fid, publicurl, err)
  37. }