mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-26 09:42:22 +00:00
io: fix TestMakeDirForFile* tests
Problem: ``` --- FAIL: TestMakeDirForFile_HappyPath (0.01s) testing.go:894: TempDir RemoveAll cleanup: remove C:\Users\Anna\AppData\Local\Temp\TestMakeDirForFile_HappyPath402638411\001\testDir\testFile.test: The process cannot access the file because it is being used by another process. --- FAIL: TestMakeDirForFile_Negative (0.01s) testing.go:894: TempDir RemoveAll cleanup: remove C:\Users\Anna\AppData\Local\Temp\TestMakeDirForFile_Negative672737582\001\testFile.test: The process cannot access the file because it is being used by another process. FAIL ``` Solution: Release resources occupied by os.Create.
This commit is contained in:
parent
06beb4d534
commit
7c48177bf7
1 changed files with 5 additions and 3 deletions
|
@ -10,19 +10,21 @@ import (
|
||||||
|
|
||||||
func TestMakeDirForFile_HappyPath(t *testing.T) {
|
func TestMakeDirForFile_HappyPath(t *testing.T) {
|
||||||
tempDir := t.TempDir()
|
tempDir := t.TempDir()
|
||||||
filePath := path.Join(tempDir, "testDir/testFile.test")
|
filePath := path.Join(tempDir, "testDir", "testFile.test")
|
||||||
err := MakeDirForFile(filePath, "test")
|
err := MakeDirForFile(filePath, "test")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
_, errChDir := os.Create(filePath)
|
f, errChDir := os.Create(filePath)
|
||||||
require.NoError(t, errChDir)
|
require.NoError(t, errChDir)
|
||||||
|
require.NoError(t, f.Close())
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMakeDirForFile_Negative(t *testing.T) {
|
func TestMakeDirForFile_Negative(t *testing.T) {
|
||||||
tempDir := t.TempDir()
|
tempDir := t.TempDir()
|
||||||
filePath := path.Join(tempDir, "testFile.test")
|
filePath := path.Join(tempDir, "testFile.test")
|
||||||
_, err := os.Create(filePath)
|
f, err := os.Create(filePath)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
require.NoError(t, f.Close())
|
||||||
|
|
||||||
filePath = path.Join(filePath, "error")
|
filePath = path.Join(filePath, "error")
|
||||||
err = MakeDirForFile(filePath, "test")
|
err = MakeDirForFile(filePath, "test")
|
||||||
|
|
Loading…
Reference in a new issue