MCPcopy
hub / github.com/qax-os/excelize / TestRemoveTempFiles

Function TestRemoveTempFiles

file_test.go:176–195  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

174}
175
176func TestRemoveTempFiles(t *testing.T) {
177 tmp, err := os.CreateTemp("", "excelize-*")
178 if err != nil {
179 t.Fatal(err)
180 }
181 tmpName := tmp.Name()
182 tmp.Close()
183 f := NewFile()
184 // fill the tempFiles map with non-existing (erroring on Remove) "files"
185 for i := 0; i < 1000; i++ {
186 f.tempFiles.Store(strconv.Itoa(i), "/hopefully not existing")
187 }
188 f.tempFiles.Store("existing", tmpName)
189
190 require.Error(t, f.Close())
191 if _, err := os.Stat(tmpName); err == nil {
192 t.Errorf("temp file %q still exist", tmpName)
193 os.Remove(tmpName)
194 }
195}

Callers

nothing calls this directly

Calls 4

CloseMethod · 0.95
NewFileFunction · 0.85
CloseMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected