(t *testing.T)
| 446 | } |
| 447 | |
| 448 | func TestFileStorage_Read_NotFound(t *testing.T) { |
| 449 | if !testutils.IsSingleTesting() { |
| 450 | return |
| 451 | } |
| 452 | |
| 453 | var storage = NewFileStorage(&serverconfigs.HTTPCachePolicy{ |
| 454 | Id: 1, |
| 455 | IsOn: true, |
| 456 | Options: map[string]interface{}{ |
| 457 | "dir": Tea.Root + "/caches", |
| 458 | }, |
| 459 | }) |
| 460 | |
| 461 | defer storage.Stop() |
| 462 | |
| 463 | err := storage.Init() |
| 464 | if err != nil { |
| 465 | t.Fatal(err) |
| 466 | } |
| 467 | now := time.Now() |
| 468 | buf := make([]byte, 6) |
| 469 | reader, err := storage.OpenReader("my-key-10000", false, false) |
| 470 | if err != nil { |
| 471 | if err == ErrNotFound { |
| 472 | t.Log("cache not fund") |
| 473 | return |
| 474 | } |
| 475 | t.Fatal(err) |
| 476 | } |
| 477 | |
| 478 | err = reader.ReadBody(buf, func(n int) (goNext bool, err error) { |
| 479 | t.Log("body:", string(buf[:n])) |
| 480 | return true, nil |
| 481 | }) |
| 482 | if err != nil { |
| 483 | t.Fatal(err) |
| 484 | } |
| 485 | t.Log(time.Since(now).Seconds()*1000, "ms") |
| 486 | } |
| 487 | |
| 488 | func TestFileStorage_Delete(t *testing.T) { |
| 489 | if !testutils.IsSingleTesting() { |
nothing calls this directly
no test coverage detected