mirror of
https://blitiri.com.ar/repos/chasquid
synced 2025-12-17 14:37:02 +00:00
protoio: Test some I/O errors
This patch adds some test cases for I/O errors, in particular when reading, writing and listing from files that don't exist or that we shouldn't have permissions to access.
This commit is contained in:
@@ -87,3 +87,22 @@ func TestStore(t *testing.T) {
|
|||||||
t.Errorf("expected [f], got %v - %v", ids, err)
|
t.Errorf("expected [f], got %v - %v", ids, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestFileErrors(t *testing.T) {
|
||||||
|
dir := testlib.MustTempDir(t)
|
||||||
|
defer testlib.RemoveIfOk(t, dir)
|
||||||
|
pb := &testpb.M{Content: "hola"}
|
||||||
|
|
||||||
|
if err := WriteMessage("/proc/doesnotexist", pb, 0600); err == nil {
|
||||||
|
t.Errorf("write to /proc/doesnotexist worked, expected error")
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := ReadMessage("/doesnotexist", pb); err == nil {
|
||||||
|
t.Errorf("read from /doesnotexist worked, expected error")
|
||||||
|
}
|
||||||
|
|
||||||
|
s := &Store{dir: "/doesnotexist"}
|
||||||
|
if ids, err := s.ListIDs(); !(ids == nil && err != nil) {
|
||||||
|
t.Errorf("list /doesnotexist worked (%v, %v), expected error", ids, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user