MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / TestFileStorage_Read_NotFound

Function TestFileStorage_Read_NotFound

internal/caches/storage_file_test.go:448–486  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

446}
447
448func 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
488func TestFileStorage_Delete(t *testing.T) {
489 if !testutils.IsSingleTesting() {

Callers

nothing calls this directly

Calls 7

IsSingleTestingFunction · 0.92
NewFileStorageFunction · 0.85
LogMethod · 0.80
StopMethod · 0.65
InitMethod · 0.65
OpenReaderMethod · 0.65
ReadBodyMethod · 0.65

Tested by

no test coverage detected