test: shred pkg

pull/7/head
sundowndev 2022-11-17 18:35:06 +04:00
parent 70bb6ade88
commit a67d06446f
3 changed files with 4 additions and 4 deletions

View File

@ -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)
} }

View File

@ -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"),
}, },
} }

0
lib/shred/testdata/empty.log vendored Normal file
View File