(t *testing.T)
| 263 | } |
| 264 | |
| 265 | func TestFileUploadAndDownload(t *testing.T) { |
| 266 | keys := make(map[string]struct{}) |
| 267 | for name := range userNames { |
| 268 | id, err := client.Login(name, passwd[name]) |
| 269 | if err != nil { |
| 270 | t.Fatalf("Login error:%v", err) |
| 271 | } |
| 272 | t.Logf("login user:%v, id:%d", name, id) |
| 273 | key, err := client.FileUpload([]byte(name)) |
| 274 | if err != nil { |
| 275 | t.Fatalf("FileUpload error:%v", err) |
| 276 | } |
| 277 | |
| 278 | t.Logf("upload user:%s, file:%s", name, key) |
| 279 | if _, ok := keys[key]; ok { |
| 280 | t.Fatalf("key:%s exist", key) |
| 281 | } |
| 282 | keys[key] = struct{}{} |
| 283 | |
| 284 | ok, err := client.FileExist(key) |
| 285 | if err != nil { |
| 286 | t.Fatalf("FileExist error:%v", err) |
| 287 | } |
| 288 | |
| 289 | if !ok { |
| 290 | t.Fatalf("key:%s not exist", key) |
| 291 | } |
| 292 | data, err := client.FileDownload(key) |
| 293 | if err != nil { |
| 294 | t.Fatalf("FileDownload error:%v", err) |
| 295 | } |
| 296 | if !bytes.Equal(data, []byte(name)) { |
| 297 | t.Fatalf("FileDownload key:%s, val:%s, expect:%s", key, data, name) |
| 298 | } |
| 299 | } |
| 300 | } |
| 301 | |
| 302 | func TestHeartbeat(t *testing.T) { |
| 303 | err := client.Heartbeat() |
nothing calls this directly
no test coverage detected