(t *testing.T)
| 12 | ) |
| 13 | |
| 14 | func TestFileReader_Read_SmallBuf(t *testing.T) { |
| 15 | bFile, err := bfs.OpenBlocksFile("testdata/test.b", bfs.DefaultBlockFileOptions) |
| 16 | if err != nil { |
| 17 | t.Fatal(err) |
| 18 | } |
| 19 | |
| 20 | reader, err := bFile.OpenFileReader(bfs.Hash("123456"), false) |
| 21 | if err != nil { |
| 22 | if os.IsNotExist(err) { |
| 23 | t.Log(err) |
| 24 | return |
| 25 | } |
| 26 | t.Fatal(err) |
| 27 | } |
| 28 | |
| 29 | defer func() { |
| 30 | _ = reader.Close() |
| 31 | }() |
| 32 | |
| 33 | var buf = make([]byte, 3) |
| 34 | for { |
| 35 | n, readErr := reader.Read(buf) |
| 36 | if n > 0 { |
| 37 | t.Log(string(buf[:n])) |
| 38 | } |
| 39 | if readErr != nil { |
| 40 | if readErr == io.EOF { |
| 41 | break |
| 42 | } |
| 43 | t.Fatal(readErr) |
| 44 | } |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | func TestFileReader_Read_LargeBuff(t *testing.T) { |
| 49 | bFile, err := bfs.OpenBlocksFile("testdata/test.b", bfs.DefaultBlockFileOptions) |
nothing calls this directly
no test coverage detected