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

Function TestFileWriter_WriteBodyAt

internal/utils/bfs/file_writer_test.go:107–134  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

105}
106
107func TestFileWriter_WriteBodyAt(t *testing.T) {
108 bFile, err := bfs.OpenBlocksFile("testdata/test.b", bfs.DefaultBlockFileOptions)
109 if err != nil {
110 t.Fatal(err)
111 }
112
113 defer func() {
114 if !testutils.IsSingleTesting() {
115 _ = bFile.RemoveAll()
116 } else {
117 _ = bFile.Close()
118 }
119 }()
120
121 writer, err := bFile.OpenFileWriter(bfs.Hash("123456"), 1<<20, true)
122 if err != nil {
123 t.Fatal(err)
124 }
125
126 {
127 n, writeErr := writer.WriteBodyAt([]byte("Hello,World"), 1024)
128 if writeErr != nil {
129 t.Fatal(writeErr)
130 }
131
132 t.Log("wrote:", n, "bytes")
133 }
134}

Callers

nothing calls this directly

Calls 8

OpenBlocksFileFunction · 0.92
IsSingleTestingFunction · 0.92
HashFunction · 0.92
WriteBodyAtMethod · 0.80
LogMethod · 0.80
CloseMethod · 0.65
RemoveAllMethod · 0.45
OpenFileWriterMethod · 0.45

Tested by

no test coverage detected