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

Function TestFileReader_Read_LargeBuff

internal/utils/bfs/file_reader_test.go:48–84  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

46}
47
48func TestFileReader_Read_LargeBuff(t *testing.T) {
49 bFile, err := bfs.OpenBlocksFile("testdata/test.b", bfs.DefaultBlockFileOptions)
50 if err != nil {
51 if os.IsNotExist(err) {
52 t.Log(err)
53 return
54 }
55 t.Fatal(err)
56 }
57
58 reader, err := bFile.OpenFileReader(bfs.Hash("123456"), false)
59 if err != nil {
60 if os.IsNotExist(err) {
61 t.Log(err)
62 return
63 }
64 t.Fatal(err)
65 }
66
67 defer func() {
68 _ = reader.Close()
69 }()
70
71 var buf = make([]byte, 128)
72 for {
73 n, readErr := reader.Read(buf)
74 if n > 0 {
75 t.Log(string(buf[:n]))
76 }
77 if readErr != nil {
78 if readErr == io.EOF {
79 break
80 }
81 t.Fatal(readErr)
82 }
83 }
84}
85
86func TestFileReader_Read_LargeFile(t *testing.T) {
87 bFile, err := bfs.OpenBlocksFile("testdata/test.b", bfs.DefaultBlockFileOptions)

Callers

nothing calls this directly

Calls 6

OpenBlocksFileFunction · 0.92
HashFunction · 0.92
LogMethod · 0.80
CloseMethod · 0.65
ReadMethod · 0.65
OpenFileReaderMethod · 0.45

Tested by

no test coverage detected