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

Function TestFS_OpenFileWriter_Close

internal/utils/bfs/fs_test.go:126–197  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

124}
125
126func TestFS_OpenFileWriter_Close(t *testing.T) {
127 if !testutils.IsSingleTesting() {
128 return
129 }
130
131 fs, openErr := bfs.OpenFS(Tea.Root+"/data/bfs/test", &bfs.FSOptions{
132 MaxOpenFiles: 99,
133 })
134 if openErr != nil {
135 t.Fatal(openErr)
136 }
137 defer func() {
138 _ = fs.Close()
139 }()
140
141 var count = 2
142 if testutils.IsSingleTesting() {
143 count = 100
144 }
145
146 for i := 0; i < count; i++ {
147 //t.Log("open", i)
148 writer, err := fs.OpenFileWriter(bfs.Hash(types.String(i)), -1, false)
149 if err != nil {
150 t.Fatal(err)
151 }
152 _ = writer.Close()
153 }
154
155 t.Log(len(fs.TestBMap()), "block files, pid:", os.Getpid())
156
157 var p = func() {
158 var bNames []string
159 fs.TestBList().Range(func(item *linkedlist.Item[string]) (goNext bool) {
160 bNames = append(bNames, item.Value)
161 return true
162 })
163
164 if len(bNames) != len(fs.TestBMap()) {
165 t.Fatal("len(bNames)!=len(bMap)")
166 }
167
168 if len(bNames) < 10 {
169 t.Log("["+types.String(len(bNames))+"]", bNames)
170 } else {
171 t.Log("["+types.String(len(bNames))+"]", bNames[:10], "...")
172 }
173 }
174
175 p()
176
177 {
178 writer, err := fs.OpenFileWriter(bfs.Hash(types.String(10)), -1, false)
179 if err != nil {
180 t.Fatal(err)
181 }
182 _ = writer.Close()
183 }

Callers

nothing calls this directly

Calls 10

IsSingleTestingFunction · 0.92
OpenFSFunction · 0.92
HashFunction · 0.92
LogMethod · 0.80
TestBMapMethod · 0.80
RangeMethod · 0.80
TestBListMethod · 0.80
CloseMethod · 0.65
OpenFileWriterMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected