Skip to content

Commit

Permalink
more tests not yet covered
Browse files Browse the repository at this point in the history
  • Loading branch information
balazsgrill committed Jul 13, 2024
1 parent d549794 commit 61b6a5c
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions filesystem_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,3 +310,61 @@ func TestChangedOnBackend(t *testing.T) {
t.Errorf("expected %v, got %v", data, data2)
}
}

func TestDeletedOnBackend(t *testing.T) {
instance := newTestInstance(t)
instance.start()
defer instance.stop()
data := []byte("something")
filename := "test.txt"
err := afero.WriteFile(instance.fs, filename, data, 0x777)
if err != nil {
t.Fatal(err)
}
err = instance.osRemoveFile(filename)
if err != nil {
t.Fatal(err)
}
_, err = instance.fs.Stat(filename)
if err != nil {
if os.IsNotExist(err) {
//ok
return
}
t.Fatal(err)
} else {
t.Error("File exists")
}
}

func TestUpdatedLocallyWhileOffline(t *testing.T) {
instance := newTestInstance(t)
instance.start()

data := []byte("something")
filename := "test.txt"
err := instance.osWriteFile(filename, string(data))

if err != nil {
t.Fatal(err)
}

instance.stop()

data = []byte("somethingelse")
err = instance.osWriteFile(filename, string(data))
if err != nil {
t.Fatal(err)
}

instance.start()

data2, err := afero.ReadFile(instance.fs, filename)
if err != nil {
t.Fatal(err)
}
if !bytes.Equal(data, data2) {
t.Errorf("expected %s, got %s", string(data), string(data2))
}
instance.stop()
}

0 comments on commit 61b6a5c

Please sign in to comment.