Просмотр исходного кода

tests: messagediff argument order should be expected, actual

So that the diff describes the changes that happened in actual as
compared to expected. The opposite is confusing.
Jakob Borg 10 лет назад
Родитель
Сommit
c439c543d0
4 измененных файлов с 23 добавлено и 23 удалено
  1. 10 10
      lib/config/config_test.go
  2. 2 2
      lib/db/set_test.go
  3. 10 10
      lib/model/queue_test.go
  4. 1 1
      lib/scanner/walk_test.go

+ 10 - 10
lib/config/config_test.go

@@ -65,7 +65,7 @@ func TestDefaultValues(t *testing.T) {
 
 	cfg := New(device1)
 
-	if diff, equal := messagediff.PrettyDiff(cfg.Options, expected); !equal {
+	if diff, equal := messagediff.PrettyDiff(expected, cfg.Options); !equal {
 		t.Errorf("Default config differs. Diff:\n%s", diff)
 	}
 }
@@ -133,13 +133,13 @@ func TestDeviceConfig(t *testing.T) {
 		if cfg.Version != CurrentVersion {
 			t.Errorf("%d: Incorrect version %d != %d", i, cfg.Version, CurrentVersion)
 		}
-		if diff, equal := messagediff.PrettyDiff(cfg.Folders, expectedFolders); !equal {
+		if diff, equal := messagediff.PrettyDiff(expectedFolders, cfg.Folders); !equal {
 			t.Errorf("%d: Incorrect Folders. Diff:\n%s", i, diff)
 		}
-		if diff, equal := messagediff.PrettyDiff(cfg.Devices, expectedDevices); !equal {
+		if diff, equal := messagediff.PrettyDiff(expectedDevices, cfg.Devices); !equal {
 			t.Errorf("%d: Incorrect Devices. Diff:\n%s", i, diff)
 		}
-		if diff, equal := messagediff.PrettyDiff(cfg.Folders[0].DeviceIDs(), expectedDeviceIDs); !equal {
+		if diff, equal := messagediff.PrettyDiff(expectedDeviceIDs, cfg.Folders[0].DeviceIDs()); !equal {
 			t.Errorf("%d: Incorrect DeviceIDs. Diff:\n%s", i, diff)
 		}
 	}
@@ -153,7 +153,7 @@ func TestNoListenAddress(t *testing.T) {
 
 	expected := []string{""}
 	actual := cfg.Options().ListenAddress
-	if diff, equal := messagediff.PrettyDiff(actual, expected); !equal {
+	if diff, equal := messagediff.PrettyDiff(expected, actual); !equal {
 		t.Errorf("Unexpected ListenAddress. Diff:\n%s", diff)
 	}
 }
@@ -197,7 +197,7 @@ func TestOverriddenValues(t *testing.T) {
 		t.Error(err)
 	}
 
-	if diff, equal := messagediff.PrettyDiff(cfg.Options(), expected); !equal {
+	if diff, equal := messagediff.PrettyDiff(expected, cfg.Options()); !equal {
 		t.Errorf("Overridden config differs. Diff:\n%s", diff)
 	}
 }
@@ -231,7 +231,7 @@ func TestDeviceAddressesDynamic(t *testing.T) {
 	}
 
 	actual := cfg.Devices()
-	if diff, equal := messagediff.PrettyDiff(actual, expected); !equal {
+	if diff, equal := messagediff.PrettyDiff(expected, actual); !equal {
 		t.Errorf("Devices differ. Diff:\n%s", diff)
 	}
 }
@@ -268,7 +268,7 @@ func TestDeviceCompression(t *testing.T) {
 	}
 
 	actual := cfg.Devices()
-	if diff, equal := messagediff.PrettyDiff(actual, expected); !equal {
+	if diff, equal := messagediff.PrettyDiff(expected, actual); !equal {
 		t.Errorf("Devices differ. Diff:\n%s", diff)
 	}
 }
@@ -302,7 +302,7 @@ func TestDeviceAddressesStatic(t *testing.T) {
 	}
 
 	actual := cfg.Devices()
-	if diff, equal := messagediff.PrettyDiff(actual, expected); !equal {
+	if diff, equal := messagediff.PrettyDiff(expected, actual); !equal {
 		t.Errorf("Devices differ. Diff:\n%s", diff)
 	}
 }
@@ -325,7 +325,7 @@ func TestVersioningConfig(t *testing.T) {
 		"foo": "bar",
 		"baz": "quux",
 	}
-	if diff, equal := messagediff.PrettyDiff(vc.Params, expected); !equal {
+	if diff, equal := messagediff.PrettyDiff(expected, vc.Params); !equal {
 		t.Errorf("vc.Params differ. Diff:\n%s", diff)
 	}
 }

+ 2 - 2
lib/db/set_test.go

@@ -533,7 +533,7 @@ func TestListDropFolder(t *testing.T) {
 
 	expectedFolderList := []string{"test0", "test1"}
 	actualFolderList := ldb.ListFolders()
-	if diff, equal := messagediff.PrettyDiff(actualFolderList, expectedFolderList); !equal {
+	if diff, equal := messagediff.PrettyDiff(expectedFolderList, actualFolderList); !equal {
 		t.Fatalf("FolderList mismatch. Diff:\n%s", diff)
 	}
 	if l := len(globalList(s0)); l != 3 {
@@ -549,7 +549,7 @@ func TestListDropFolder(t *testing.T) {
 
 	expectedFolderList = []string{"test0"}
 	actualFolderList = ldb.ListFolders()
-	if diff, equal := messagediff.PrettyDiff(actualFolderList, expectedFolderList); !equal {
+	if diff, equal := messagediff.PrettyDiff(expectedFolderList, actualFolderList); !equal {
 		t.Fatalf("FolderList mismatch. Diff:\n%s", diff)
 	}
 	if l := len(globalList(s0)); l != 3 {

+ 10 - 10
lib/model/queue_test.go

@@ -127,35 +127,35 @@ func TestBringToFront(t *testing.T) {
 	q.Push("f4", 0, 0)
 
 	_, queued := q.Jobs()
-	if diff, equal := messagediff.PrettyDiff(queued, []string{"f1", "f2", "f3", "f4"}); !equal {
+	if diff, equal := messagediff.PrettyDiff([]string{"f1", "f2", "f3", "f4"}, queued); !equal {
 		t.Errorf("Order does not match. Diff:\n%s", diff)
 	}
 
 	q.BringToFront("f1") // corner case: does nothing
 
 	_, queued = q.Jobs()
-	if diff, equal := messagediff.PrettyDiff(queued, []string{"f1", "f2", "f3", "f4"}); !equal {
+	if diff, equal := messagediff.PrettyDiff([]string{"f1", "f2", "f3", "f4"}, queued); !equal {
 		t.Errorf("Order does not match. Diff:\n%s", diff)
 	}
 
 	q.BringToFront("f3")
 
 	_, queued = q.Jobs()
-	if diff, equal := messagediff.PrettyDiff(queued, []string{"f3", "f1", "f2", "f4"}); !equal {
+	if diff, equal := messagediff.PrettyDiff([]string{"f3", "f1", "f2", "f4"}, queued); !equal {
 		t.Errorf("Order does not match. Diff:\n%s", diff)
 	}
 
 	q.BringToFront("f2")
 
 	_, queued = q.Jobs()
-	if diff, equal := messagediff.PrettyDiff(queued, []string{"f2", "f3", "f1", "f4"}); !equal {
+	if diff, equal := messagediff.PrettyDiff([]string{"f2", "f3", "f1", "f4"}, queued); !equal {
 		t.Errorf("Order does not match. Diff:\n%s", diff)
 	}
 
 	q.BringToFront("f4") // corner case: last element
 
 	_, queued = q.Jobs()
-	if diff, equal := messagediff.PrettyDiff(queued, []string{"f4", "f2", "f3", "f1"}); !equal {
+	if diff, equal := messagediff.PrettyDiff([]string{"f4", "f2", "f3", "f1"}, queued); !equal {
 		t.Errorf("Order does not match. Diff:\n%s", diff)
 	}
 }
@@ -176,7 +176,7 @@ func TestShuffle(t *testing.T) {
 		}
 
 		t.Logf("%v", queued)
-		if _, equal := messagediff.PrettyDiff(queued, []string{"f1", "f2", "f3", "f4"}); !equal {
+		if _, equal := messagediff.PrettyDiff([]string{"f1", "f2", "f3", "f4"}, queued); !equal {
 			// The queue was shuffled
 			return
 		}
@@ -200,7 +200,7 @@ func TestSortBySize(t *testing.T) {
 	}
 	expected := []string{"f4", "f1", "f3", "f2"}
 
-	if diff, equal := messagediff.PrettyDiff(actual, expected); !equal {
+	if diff, equal := messagediff.PrettyDiff(expected, actual); !equal {
 		t.Errorf("SortSmallestFirst() diff:\n%s", diff)
 	}
 
@@ -212,7 +212,7 @@ func TestSortBySize(t *testing.T) {
 	}
 	expected = []string{"f2", "f3", "f1", "f4"}
 
-	if diff, equal := messagediff.PrettyDiff(actual, expected); !equal {
+	if diff, equal := messagediff.PrettyDiff(expected, actual); !equal {
 		t.Errorf("SortLargestFirst() diff:\n%s", diff)
 	}
 }
@@ -232,7 +232,7 @@ func TestSortByAge(t *testing.T) {
 	}
 	expected := []string{"f4", "f1", "f3", "f2"}
 
-	if diff, equal := messagediff.PrettyDiff(actual, expected); !equal {
+	if diff, equal := messagediff.PrettyDiff(expected, actual); !equal {
 		t.Errorf("SortOldestFirst() diff:\n%s", diff)
 	}
 
@@ -244,7 +244,7 @@ func TestSortByAge(t *testing.T) {
 	}
 	expected = []string{"f2", "f3", "f1", "f4"}
 
-	if diff, equal := messagediff.PrettyDiff(actual, expected); !equal {
+	if diff, equal := messagediff.PrettyDiff(expected, actual); !equal {
 		t.Errorf("SortNewestFirst() diff:\n%s", diff)
 	}
 }

+ 1 - 1
lib/scanner/walk_test.go

@@ -120,7 +120,7 @@ func TestWalk(t *testing.T) {
 	sort.Sort(fileList(tmp))
 	files := fileList(tmp).testfiles()
 
-	if diff, equal := messagediff.PrettyDiff(files, testdata); !equal {
+	if diff, equal := messagediff.PrettyDiff(testdata, files); !equal {
 		t.Errorf("Walk returned unexpected data. Diff:\n%s", diff)
 	}
 }