lib/model: Introduce must test utility (#5586)

* lib/model: Introduce must test utility

* nice
This commit is contained in:
Simon Frei
2019-03-09 19:45:36 +01:00
committed by Audrius Butkevicius
parent 27ff20faa3
commit 189e44488e
5 changed files with 58 additions and 168 deletions

View File

@@ -482,9 +482,7 @@ func TestRescanIfHaveInvalidContent(t *testing.T) {
payload := []byte("hello")
if err := ioutil.WriteFile(filepath.Join(tmpDir, "foo"), payload, 0777); err != nil {
t.Fatal(err)
}
must(t, ioutil.WriteFile(filepath.Join(tmpDir, "foo"), payload, 0777))
received := make(chan protocol.FileInfo)
fc.mut.Lock()
@@ -521,9 +519,7 @@ func TestRescanIfHaveInvalidContent(t *testing.T) {
payload = []byte("bye")
buf = make([]byte, len(payload))
if err := ioutil.WriteFile(filepath.Join(tmpDir, "foo"), payload, 0777); err != nil {
t.Fatal(err)
}
must(t, ioutil.WriteFile(filepath.Join(tmpDir, "foo"), payload, 0777))
_, err = m.Request(device1, "default", "foo", int32(len(payload)), 0, f.Blocks[0].Hash, f.Blocks[0].WeakHash, false)
if err == nil {
@@ -573,9 +569,7 @@ func TestParentDeletion(t *testing.T) {
}
// Delete parent dir
if err := testFs.RemoveAll(parent); err != nil {
t.Fatal(err)
}
must(t, testFs.RemoveAll(parent))
// Scan only the child dir (not the parent)
if err := m.ScanFolderSubdirs("default", []string{child}); err != nil {
@@ -783,9 +777,7 @@ func TestRequestRemoteRenameChanged(t *testing.T) {
}
for _, n := range [2]string{a, b} {
if err := equalContents(filepath.Join(tmpDir, n), data[n]); err != nil {
t.Fatal(err)
}
must(t, equalContents(filepath.Join(tmpDir, n), data[n]))
}
var gotA, gotB, gotConfl bool
@@ -912,9 +904,7 @@ func TestRequestRemoteRenameConflict(t *testing.T) {
}
for _, n := range [2]string{a, b} {
if err := equalContents(filepath.Join(tmpDir, n), data[n]); err != nil {
t.Fatal(err)
}
must(t, equalContents(filepath.Join(tmpDir, n), data[n]))
}
fd, err := tfs.OpenFile(b, fs.OptReadWrite, 0644)