(t *testing.T)
| 343 | } |
| 344 | |
| 345 | func TestFileStorage_Read(t *testing.T) { |
| 346 | if !testutils.IsSingleTesting() { |
| 347 | return |
| 348 | } |
| 349 | |
| 350 | var storage = NewFileStorage(&serverconfigs.HTTPCachePolicy{ |
| 351 | Id: 1, |
| 352 | IsOn: true, |
| 353 | Options: map[string]interface{}{ |
| 354 | "dir": Tea.Root + "/caches", |
| 355 | }, |
| 356 | }) |
| 357 | |
| 358 | defer storage.Stop() |
| 359 | |
| 360 | err := storage.Init() |
| 361 | if err != nil { |
| 362 | t.Fatal(err) |
| 363 | } |
| 364 | now := time.Now() |
| 365 | reader, err := storage.OpenReader("my-key", false, false) |
| 366 | if err != nil { |
| 367 | t.Fatal(err) |
| 368 | } |
| 369 | buf := make([]byte, 6) |
| 370 | t.Log(reader.Status()) |
| 371 | err = reader.ReadHeader(buf, func(n int) (goNext bool, err error) { |
| 372 | t.Log("header:", string(buf[:n])) |
| 373 | return true, nil |
| 374 | }) |
| 375 | if err != nil { |
| 376 | t.Fatal(err) |
| 377 | } |
| 378 | err = reader.ReadBody(buf, func(n int) (goNext bool, err error) { |
| 379 | t.Log("body:", string(buf[:n])) |
| 380 | return true, nil |
| 381 | }) |
| 382 | if err != nil { |
| 383 | t.Fatal(err) |
| 384 | } |
| 385 | t.Log(time.Since(now).Seconds()*1000, "ms") |
| 386 | } |
| 387 | |
| 388 | func TestFileStorage_Read_HTTP_Response(t *testing.T) { |
| 389 | if !testutils.IsSingleTesting() { |
nothing calls this directly
no test coverage detected