aboutsummaryrefslogtreecommitdiff
path: root/repo_test.go
diff options
context:
space:
mode:
authorn-peugnet <n.peugnet@free.fr>2021-09-21 12:45:10 +0200
committern-peugnet <n.peugnet@free.fr>2021-09-21 12:45:10 +0200
commitd7faf55344a3d86e6d64618ead449b3fbbd88612 (patch)
treec1183e06a58a403e3162834ff3e39bb764b59926 /repo_test.go
parentb34c0a4c877f5d39174fbffdbf9821a6895b8422 (diff)
downloaddna-backup-d7faf55344a3d86e6d64618ead449b3fbbd88612.tar.gz
dna-backup-d7faf55344a3d86e6d64618ead449b3fbbd88612.zip
Use assertSame instead of assertSlice
Diffstat (limited to 'repo_test.go')
-rw-r--r--repo_test.go18
1 files changed, 3 insertions, 15 deletions
diff --git a/repo_test.go b/repo_test.go
index ed2cd28..30f2982 100644
--- a/repo_test.go
+++ b/repo_test.go
@@ -376,10 +376,7 @@ func assertCompatibleRepoFile(t *testing.T, expected string, actual string, pref
// Recipe file
eRecipe := loadRecipe(expected)
aRecipe := loadRecipe(actual)
- assertLen(t, len(eRecipe), aRecipe, prefix)
- for i, eChunk := range eRecipe {
- assertSame(t, eChunk, aRecipe[i], prefix+" chunks")
- }
+ assertSame(t, eRecipe, aRecipe, prefix+"recipe")
} else if filepath.Base(expected) == hashesName {
// Hashes file is checked in TestHashes
} else {
@@ -397,7 +394,7 @@ func assertSameFile(t *testing.T, expected string, actual string, prefix string)
if err != nil {
t.Fatalf("%s Error reading from expected file '%s': %s", prefix, actual, err)
}
- assertSameSlice(t, efContent, afContent, prefix+" files")
+ assertSame(t, efContent, afContent, prefix+" files")
}
func assertLen(t *testing.T, expected int, actual interface{}, prefix string) {
@@ -407,21 +404,12 @@ func assertLen(t *testing.T, expected int, actual interface{}, prefix string) {
}
}
-func assertSameSlice(t *testing.T, expected []byte, actual []byte, prefix string) {
- assertLen(t, len(expected), actual, prefix)
- for i := 0; i < len(expected); i++ {
- if expected[i] != actual[i] {
- t.Fatal(prefix, "incorrect value", i, ", expected:", expected[i], ", actual:", actual[i])
- }
- }
-}
-
func assertChunkContent(t *testing.T, expected []byte, c Chunk, prefix string) {
buf, err := io.ReadAll(c.Reader())
if err != nil {
t.Fatal(err)
}
- assertSameSlice(t, expected, buf, prefix+" Chunk content")
+ assertSame(t, expected, buf, prefix+" Chunk content")
}
func assertSame(t *testing.T, expected interface{}, actual interface{}, prefix string) {