mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-09-10 07:36:27 -04:00
Close temp file handles before cleanup on Windows
Windows cannot remove files while handles are still open. In TestOSCommandFileType we created files and immediately called RemoveAll without closing handles, which left untracked artifacts (e.g. "testFile" and "file with spaces") in the working tree. Close the handles and assert RemoveAll succeeds so cleanup failures are visible.
This commit is contained in:
parent
3ffc4ac832
commit
7fbc2a8c14
|
|
@ -91,7 +91,11 @@ func TestOSCommandFileType(t *testing.T) {
|
|||
{
|
||||
"testFile",
|
||||
func() {
|
||||
if _, err := os.Create("testFile"); err != nil {
|
||||
f, err := os.Create("testFile")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err := f.Close(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
},
|
||||
|
|
@ -102,7 +106,11 @@ func TestOSCommandFileType(t *testing.T) {
|
|||
{
|
||||
"file with spaces",
|
||||
func() {
|
||||
if _, err := os.Create("file with spaces"); err != nil {
|
||||
f, err := os.Create("file with spaces")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err := f.Close(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
},
|
||||
|
|
@ -133,7 +141,7 @@ func TestOSCommandFileType(t *testing.T) {
|
|||
for _, s := range scenarios {
|
||||
s.setup()
|
||||
s.test(FileType(s.path))
|
||||
_ = os.RemoveAll(s.path)
|
||||
assert.NoError(t, os.RemoveAll(s.path))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue