Skip to content

Commit

Permalink
added new test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
gmgigi96 committed Aug 17, 2021
1 parent 21dc68e commit 5e3844b
Showing 1 changed file with 55 additions and 1 deletion.
56 changes: 55 additions & 1 deletion internal/archiver/archiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2208,6 +2208,59 @@ func TestArchiverSnapshotMerge(t *testing.T) {
"bar": TestFile{Content: "bar"},
},
},
{
name: "delete-dir-create-file-same-name-dir-in-root",
src: TestDir{
"dir": TestDir{
"subdir": TestDir{
"foo": TestFile{Content: "foo"},
"bar": TestFile{Content: "bar"},
},
},
"bar": TestFile{Content: "bar"},
},
action: func(rootDir string, t *testing.T) {
deleteFile(rootDir, "dir/subdir/foo", t)
deleteDir(rootDir, "dir/subdir", t)

createFile(rootDir, "dir/subdir", "file", t)
},
targets: []string{"dir/subdir/foo", "dir/subdir"},
want: TestDir{
"dir": TestDir{
"subdir": TestFile{Content: "file"},
},
"bar": TestFile{Content: "bar"},
},
},
{
name: "delete-dir-create-file-same-name-dir-in-subdir",
src: TestDir{
"dir": TestDir{
"subdir": TestDir{
"subsubdir": TestDir{
"foo": TestFile{Content: "foo"},
"bar": TestFile{Content: "bar"},
},
},
},
"bar": TestFile{Content: "bar"},
},
action: func(rootDir string, t *testing.T) {
deleteDir(rootDir, "dir/subdir/subsubdir", t)

createFile(rootDir, "dir/subdir/subsubdir", "file", t)
},
targets: []string{"dir/subdir/foo", "dir/subdir"},
want: TestDir{
"dir": TestDir{
"subdir": TestDir{
"subsubdir": TestFile{Content: "file"},
},
},
"bar": TestFile{Content: "bar"},
},
},
}

for _, test := range tests {
Expand All @@ -2232,6 +2285,8 @@ func TestArchiverSnapshotMerge(t *testing.T) {
t.Fatal(err)
}
t.Log("First repo check")

TestEnsureSnapshot(t, repo, snapshotSrcID, test.src)
checker.TestCheckRepo(t, repo)

test.action(tempdir, t)
Expand All @@ -2246,7 +2301,6 @@ func TestArchiverSnapshotMerge(t *testing.T) {
t.Fatal(err)
}

TestEnsureSnapshot(t, repo, snapshotSrcID, test.src)
TestEnsureSnapshot(t, repo, snapshotMergeID, test.want)

t.Log("Second repo check")
Expand Down

0 comments on commit 5e3844b

Please sign in to comment.