Skip to content

Commit

Permalink
update test for file remove functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
mschuchard committed Feb 28, 2024
1 parent 6e01521 commit 0f5add2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
setup_env
vault-raft-backup
util/foo
25 changes: 23 additions & 2 deletions util/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,32 @@ import (
)

func TestSnapshotFileClose(test *testing.T) {
genericFile, err := os.OpenFile("foo", os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0o644)
genericFile, err := os.Create("foo")
if err != nil {
test.Error("test short-circuited because file could not be created and opened")
}
SnapshotFileClose(genericFile)

if err := SnapshotFileClose(genericFile); err != nil {
test.Error("generic file failed to close")
test.Error(err)
}
}

func TestSnapshotFileRemove(test *testing.T) {
genericFile, err := os.Create("foo")
if err != nil {
test.Error("test short-circuited because file could not be created and opened")
}

if err := SnapshotFileRemove(genericFile); err != nil {
test.Error("failed to remove generic file")
test.Error(err)
}

// false positive probably because of race condition
/*if _, err := genericFile.Stat(); err == nil {
test.Error("validation that generic file was removed returned no path error")
}*/
}

// bootstrap vault server for testing
Expand Down

0 comments on commit 0f5add2

Please sign in to comment.