test: shred pkg
parent
70bb6ade88
commit
a67d06446f
|
@ -47,7 +47,7 @@ func (s *Shredder) Write(pathName string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open the file
|
// Open the file
|
||||||
file, err := os.OpenFile(pathName, os.O_WRONLY, 0777)
|
file, err := os.OpenFile(pathName, os.O_WRONLY, fstat.Mode())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("shredding failed: %w", err)
|
return fmt.Errorf("shredding failed: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,9 +21,9 @@ func TestShredder_Write(t *testing.T) {
|
||||||
wantError: errors.New("shredding failed: stat testdata/fake.log: no such file or directory"),
|
wantError: errors.New("shredding failed: stat testdata/fake.log: no such file or directory"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "test with protected file",
|
name: "test with non-file path",
|
||||||
input: "testdata/protected.log",
|
input: "testdata/",
|
||||||
wantError: errors.New("shredding failed: open testdata/protected.log: permission denied"),
|
wantError: errors.New("shredding failed: open testdata/: is a directory"),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue