mirror of
https://github.com/minio/minio.git
synced 2025-11-20 09:56:07 -05:00
Detect underlying disk mount/unmount (#8408)
This commit is contained in:
committed by
kannappanr
parent
8aaaa46be9
commit
980bf78b4d
@@ -101,3 +101,34 @@ func TestSkipReader(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestSameFile(t *testing.T) {
|
||||
f, err := goioutil.TempFile("", "")
|
||||
if err != nil {
|
||||
t.Errorf("Error creating tmp file: %v", err)
|
||||
}
|
||||
tmpFile := f.Name()
|
||||
f.Close()
|
||||
defer os.Remove(f.Name())
|
||||
fi1, err := os.Stat(tmpFile)
|
||||
if err != nil {
|
||||
t.Fatalf("Error Stat(): %v", err)
|
||||
}
|
||||
fi2, err := os.Stat(tmpFile)
|
||||
if err != nil {
|
||||
t.Fatalf("Error Stat(): %v", err)
|
||||
}
|
||||
if !SameFile(fi1, fi2) {
|
||||
t.Fatal("Expected the files to be same")
|
||||
}
|
||||
if err = goioutil.WriteFile(tmpFile, []byte("aaa"), 0644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
fi2, err = os.Stat(tmpFile)
|
||||
if err != nil {
|
||||
t.Fatalf("Error Stat(): %v", err)
|
||||
}
|
||||
if SameFile(fi1, fi2) {
|
||||
t.Fatal("Expected the files not to be same")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user