MCPcopy Index your code
hub / github.com/GoEdgeLab/EdgeNode / TestFileStorage_Read

Function TestFileStorage_Read

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

Source from the content-addressed store, hash-verified

343}
344
345func 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
388func TestFileStorage_Read_HTTP_Response(t *testing.T) {
389 if !testutils.IsSingleTesting() {

Callers

nothing calls this directly

Calls 9

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

Tested by

no test coverage detected