Add deps
This commit is contained in:
committed by
Jakob Borg
parent
dd9a4e044a
commit
a8ffde6f21
@@ -12,11 +12,11 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/d4l3k/messagediff"
|
||||
"github.com/syncthing/syncthing/lib/protocol"
|
||||
)
|
||||
|
||||
@@ -65,8 +65,8 @@ func TestDefaultValues(t *testing.T) {
|
||||
|
||||
cfg := New(device1)
|
||||
|
||||
if !reflect.DeepEqual(cfg.Options, expected) {
|
||||
t.Errorf("Default config differs;\n E: %#v\n A: %#v", expected, cfg.Options)
|
||||
if diff, equal := messagediff.PrettyDiff(cfg.Options, expected); !equal {
|
||||
t.Errorf("Default config differs. Diff:\n%s", diff)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,14 +133,14 @@ func TestDeviceConfig(t *testing.T) {
|
||||
if cfg.Version != CurrentVersion {
|
||||
t.Errorf("%d: Incorrect version %d != %d", i, cfg.Version, CurrentVersion)
|
||||
}
|
||||
if !reflect.DeepEqual(cfg.Folders, expectedFolders) {
|
||||
t.Errorf("%d: Incorrect Folders\n A: %#v\n E: %#v", i, cfg.Folders, expectedFolders)
|
||||
if diff, equal := messagediff.PrettyDiff(cfg.Folders, expectedFolders); !equal {
|
||||
t.Errorf("%d: Incorrect Folders. Diff:\n%s", i, diff)
|
||||
}
|
||||
if !reflect.DeepEqual(cfg.Devices, expectedDevices) {
|
||||
t.Errorf("%d: Incorrect Devices\n A: %#v\n E: %#v", i, cfg.Devices, expectedDevices)
|
||||
if diff, equal := messagediff.PrettyDiff(cfg.Devices, expectedDevices); !equal {
|
||||
t.Errorf("%d: Incorrect Devices. Diff:\n%s", i, diff)
|
||||
}
|
||||
if !reflect.DeepEqual(cfg.Folders[0].DeviceIDs(), expectedDeviceIDs) {
|
||||
t.Errorf("%d: Incorrect DeviceIDs\n A: %#v\n E: %#v", i, cfg.Folders[0].DeviceIDs(), expectedDeviceIDs)
|
||||
if diff, equal := messagediff.PrettyDiff(cfg.Folders[0].DeviceIDs(), expectedDeviceIDs); !equal {
|
||||
t.Errorf("%d: Incorrect DeviceIDs. Diff:\n%s", i, diff)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -153,8 +153,8 @@ func TestNoListenAddress(t *testing.T) {
|
||||
|
||||
expected := []string{""}
|
||||
actual := cfg.Options().ListenAddress
|
||||
if !reflect.DeepEqual(actual, expected) {
|
||||
t.Errorf("Unexpected ListenAddress %#v", actual)
|
||||
if diff, equal := messagediff.PrettyDiff(actual, expected); !equal {
|
||||
t.Errorf("Unexpected ListenAddress. Diff:\n%s", diff)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,8 +197,8 @@ func TestOverriddenValues(t *testing.T) {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(cfg.Options(), expected) {
|
||||
t.Errorf("Overridden config differs;\n E: %#v\n A: %#v", expected, cfg.Options())
|
||||
if diff, equal := messagediff.PrettyDiff(cfg.Options(), expected); !equal {
|
||||
t.Errorf("Overridden config differs. Diff:\n%s", diff)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -231,8 +231,8 @@ func TestDeviceAddressesDynamic(t *testing.T) {
|
||||
}
|
||||
|
||||
actual := cfg.Devices()
|
||||
if !reflect.DeepEqual(actual, expected) {
|
||||
t.Errorf("Devices differ;\n E: %#v\n A: %#v", expected, actual)
|
||||
if diff, equal := messagediff.PrettyDiff(actual, expected); !equal {
|
||||
t.Errorf("Devices differ. Diff:\n%s", diff)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -268,8 +268,8 @@ func TestDeviceCompression(t *testing.T) {
|
||||
}
|
||||
|
||||
actual := cfg.Devices()
|
||||
if !reflect.DeepEqual(actual, expected) {
|
||||
t.Errorf("Devices differ;\n E: %#v\n A: %#v", expected, actual)
|
||||
if diff, equal := messagediff.PrettyDiff(actual, expected); !equal {
|
||||
t.Errorf("Devices differ. Diff:\n%s", diff)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -302,8 +302,8 @@ func TestDeviceAddressesStatic(t *testing.T) {
|
||||
}
|
||||
|
||||
actual := cfg.Devices()
|
||||
if !reflect.DeepEqual(actual, expected) {
|
||||
t.Errorf("Devices differ;\n E: %#v\n A: %#v", expected, actual)
|
||||
if diff, equal := messagediff.PrettyDiff(actual, expected); !equal {
|
||||
t.Errorf("Devices differ. Diff:\n%s", diff)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -325,8 +325,8 @@ func TestVersioningConfig(t *testing.T) {
|
||||
"foo": "bar",
|
||||
"baz": "quux",
|
||||
}
|
||||
if !reflect.DeepEqual(vc.Params, expected) {
|
||||
t.Errorf("vc.Params differ;\n E: %#v\n A: %#v", expected, vc.Params)
|
||||
if diff, equal := messagediff.PrettyDiff(vc.Params, expected); !equal {
|
||||
t.Errorf("vc.Params differ. Diff:\n%s", diff)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -447,8 +447,8 @@ func TestNewSaveLoad(t *testing.T) {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(cfg.Raw(), cfg2.Raw()) {
|
||||
t.Errorf("Configs are not equal;\n E: %#v\n A: %#v", cfg.Raw(), cfg2.Raw())
|
||||
if diff, equal := messagediff.PrettyDiff(cfg.Raw(), cfg2.Raw()); !equal {
|
||||
t.Errorf("Configs are not equal. Diff:\n%s", diff)
|
||||
}
|
||||
|
||||
os.Remove(path)
|
||||
|
||||
@@ -10,10 +10,10 @@ import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"os"
|
||||
"reflect"
|
||||
"sort"
|
||||
"testing"
|
||||
|
||||
"github.com/d4l3k/messagediff"
|
||||
"github.com/syncthing/syncthing/lib/db"
|
||||
"github.com/syncthing/syncthing/lib/protocol"
|
||||
)
|
||||
@@ -532,8 +532,9 @@ func TestListDropFolder(t *testing.T) {
|
||||
// Check that we have both folders and their data is in the global list
|
||||
|
||||
expectedFolderList := []string{"test0", "test1"}
|
||||
if actualFolderList := ldb.ListFolders(); !reflect.DeepEqual(actualFolderList, expectedFolderList) {
|
||||
t.Fatalf("FolderList mismatch\nE: %v\nA: %v", expectedFolderList, actualFolderList)
|
||||
actualFolderList := ldb.ListFolders()
|
||||
if diff, equal := messagediff.PrettyDiff(actualFolderList, expectedFolderList); !equal {
|
||||
t.Fatalf("FolderList mismatch. Diff:\n%s", diff)
|
||||
}
|
||||
if l := len(globalList(s0)); l != 3 {
|
||||
t.Errorf("Incorrect global length %d != 3 for s0", l)
|
||||
@@ -547,8 +548,9 @@ func TestListDropFolder(t *testing.T) {
|
||||
db.DropFolder(ldb, "test1")
|
||||
|
||||
expectedFolderList = []string{"test0"}
|
||||
if actualFolderList := ldb.ListFolders(); !reflect.DeepEqual(actualFolderList, expectedFolderList) {
|
||||
t.Fatalf("FolderList mismatch\nE: %v\nA: %v", expectedFolderList, actualFolderList)
|
||||
actualFolderList = ldb.ListFolders()
|
||||
if diff, equal := messagediff.PrettyDiff(actualFolderList, expectedFolderList); !equal {
|
||||
t.Fatalf("FolderList mismatch. Diff:\n%s", diff)
|
||||
}
|
||||
if l := len(globalList(s0)); l != 3 {
|
||||
t.Errorf("Incorrect global length %d != 3 for s0", l)
|
||||
|
||||
@@ -8,8 +8,9 @@ package model
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/d4l3k/messagediff"
|
||||
)
|
||||
|
||||
func TestJobQueue(t *testing.T) {
|
||||
@@ -126,36 +127,36 @@ func TestBringToFront(t *testing.T) {
|
||||
q.Push("f4", 0, 0)
|
||||
|
||||
_, queued := q.Jobs()
|
||||
if !reflect.DeepEqual(queued, []string{"f1", "f2", "f3", "f4"}) {
|
||||
t.Errorf("Incorrect order %v at start", queued)
|
||||
if diff, equal := messagediff.PrettyDiff(queued, []string{"f1", "f2", "f3", "f4"}); !equal {
|
||||
t.Errorf("Order does not match. Diff:\n%s", diff)
|
||||
}
|
||||
|
||||
q.BringToFront("f1") // corner case: does nothing
|
||||
|
||||
_, queued = q.Jobs()
|
||||
if !reflect.DeepEqual(queued, []string{"f1", "f2", "f3", "f4"}) {
|
||||
t.Errorf("Incorrect order %v", queued)
|
||||
if diff, equal := messagediff.PrettyDiff(queued, []string{"f1", "f2", "f3", "f4"}); !equal {
|
||||
t.Errorf("Order does not match. Diff:\n%s", diff)
|
||||
}
|
||||
|
||||
q.BringToFront("f3")
|
||||
|
||||
_, queued = q.Jobs()
|
||||
if !reflect.DeepEqual(queued, []string{"f3", "f1", "f2", "f4"}) {
|
||||
t.Errorf("Incorrect order %v", queued)
|
||||
if diff, equal := messagediff.PrettyDiff(queued, []string{"f3", "f1", "f2", "f4"}); !equal {
|
||||
t.Errorf("Order does not match. Diff:\n%s", diff)
|
||||
}
|
||||
|
||||
q.BringToFront("f2")
|
||||
|
||||
_, queued = q.Jobs()
|
||||
if !reflect.DeepEqual(queued, []string{"f2", "f3", "f1", "f4"}) {
|
||||
t.Errorf("Incorrect order %v", queued)
|
||||
if diff, equal := messagediff.PrettyDiff(queued, []string{"f2", "f3", "f1", "f4"}); !equal {
|
||||
t.Errorf("Order does not match. Diff:\n%s", diff)
|
||||
}
|
||||
|
||||
q.BringToFront("f4") // corner case: last element
|
||||
|
||||
_, queued = q.Jobs()
|
||||
if !reflect.DeepEqual(queued, []string{"f4", "f2", "f3", "f1"}) {
|
||||
t.Errorf("Incorrect order %v", queued)
|
||||
if diff, equal := messagediff.PrettyDiff(queued, []string{"f4", "f2", "f3", "f1"}); !equal {
|
||||
t.Errorf("Order does not match. Diff:\n%s", diff)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,7 +176,7 @@ func TestShuffle(t *testing.T) {
|
||||
}
|
||||
|
||||
t.Logf("%v", queued)
|
||||
if !reflect.DeepEqual(queued, []string{"f1", "f2", "f3", "f4"}) {
|
||||
if _, equal := messagediff.PrettyDiff(queued, []string{"f1", "f2", "f3", "f4"}); !equal {
|
||||
// The queue was shuffled
|
||||
return
|
||||
}
|
||||
@@ -199,8 +200,8 @@ func TestSortBySize(t *testing.T) {
|
||||
}
|
||||
expected := []string{"f4", "f1", "f3", "f2"}
|
||||
|
||||
if !reflect.DeepEqual(actual, expected) {
|
||||
t.Errorf("SortSmallestFirst(): %#v != %#v", actual, expected)
|
||||
if diff, equal := messagediff.PrettyDiff(actual, expected); !equal {
|
||||
t.Errorf("SortSmallestFirst() diff:\n%s", diff)
|
||||
}
|
||||
|
||||
q.SortLargestFirst()
|
||||
@@ -211,8 +212,8 @@ func TestSortBySize(t *testing.T) {
|
||||
}
|
||||
expected = []string{"f2", "f3", "f1", "f4"}
|
||||
|
||||
if !reflect.DeepEqual(actual, expected) {
|
||||
t.Errorf("SortLargestFirst(): %#v != %#v", actual, expected)
|
||||
if diff, equal := messagediff.PrettyDiff(actual, expected); !equal {
|
||||
t.Errorf("SortLargestFirst() diff:\n%s", diff)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -231,8 +232,8 @@ func TestSortByAge(t *testing.T) {
|
||||
}
|
||||
expected := []string{"f4", "f1", "f3", "f2"}
|
||||
|
||||
if !reflect.DeepEqual(actual, expected) {
|
||||
t.Errorf("SortOldestFirst(): %#v != %#v", actual, expected)
|
||||
if diff, equal := messagediff.PrettyDiff(actual, expected); !equal {
|
||||
t.Errorf("SortOldestFirst() diff:\n%s", diff)
|
||||
}
|
||||
|
||||
q.SortNewestFirst()
|
||||
@@ -243,8 +244,8 @@ func TestSortByAge(t *testing.T) {
|
||||
}
|
||||
expected = []string{"f2", "f3", "f1", "f4"}
|
||||
|
||||
if !reflect.DeepEqual(actual, expected) {
|
||||
t.Errorf("SortNewestFirst(): %#v != %#v", actual, expected)
|
||||
if diff, equal := messagediff.PrettyDiff(actual, expected); !equal {
|
||||
t.Errorf("SortNewestFirst() diff:\n%s", diff)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -80,6 +80,7 @@ func TestInWritableDirWindowsRemove(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer os.Chmod("testdata/windows/ro/readonlynew", 0700)
|
||||
defer os.RemoveAll("testdata")
|
||||
|
||||
create := func(name string) error {
|
||||
@@ -123,6 +124,7 @@ func TestInWritableDirWindowsRename(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer os.Chmod("testdata/windows/ro/readonlynew", 0700)
|
||||
defer os.RemoveAll("testdata")
|
||||
|
||||
create := func(name string) error {
|
||||
|
||||
@@ -13,13 +13,13 @@ import (
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"runtime"
|
||||
rdebug "runtime/debug"
|
||||
"sort"
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
"github.com/d4l3k/messagediff"
|
||||
"github.com/syncthing/syncthing/lib/ignore"
|
||||
"github.com/syncthing/syncthing/lib/osutil"
|
||||
"github.com/syncthing/syncthing/lib/protocol"
|
||||
@@ -120,8 +120,8 @@ func TestWalk(t *testing.T) {
|
||||
sort.Sort(fileList(tmp))
|
||||
files := fileList(tmp).testfiles()
|
||||
|
||||
if !reflect.DeepEqual(files, testdata) {
|
||||
t.Errorf("Walk returned unexpected data\nExpected: %v\nActual: %v", testdata, files)
|
||||
if diff, equal := messagediff.PrettyDiff(files, testdata); !equal {
|
||||
t.Errorf("Walk returned unexpected data. Diff:\n%s", diff)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user