mirror of
https://github.com/octoleo/restic.git
synced 2024-11-29 08:14:03 +00:00
archiver: Check that duplicates are only ignored if identical
This commit is contained in:
parent
403b01b788
commit
5278ab51c8
@ -8,6 +8,7 @@ import (
|
||||
|
||||
"github.com/restic/restic/internal/errors"
|
||||
"github.com/restic/restic/internal/restic"
|
||||
"github.com/restic/restic/internal/test"
|
||||
"golang.org/x/sync/errgroup"
|
||||
)
|
||||
|
||||
@ -119,3 +120,41 @@ func TestTreeSaverError(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestTreeSaverDuplicates(t *testing.T) {
|
||||
for _, identicalNodes := range []bool{true, false} {
|
||||
t.Run("", func(t *testing.T) {
|
||||
ctx, cancel, b, shutdown := setupTreeSaver()
|
||||
defer cancel()
|
||||
|
||||
node := &restic.Node{
|
||||
Name: "file",
|
||||
}
|
||||
nodes := []FutureNode{
|
||||
newFutureNodeWithResult(futureNodeResult{node: &restic.Node{
|
||||
Name: "child",
|
||||
}}),
|
||||
}
|
||||
if identicalNodes {
|
||||
nodes = append(nodes, newFutureNodeWithResult(futureNodeResult{node: &restic.Node{
|
||||
Name: "child",
|
||||
}}))
|
||||
} else {
|
||||
nodes = append(nodes, newFutureNodeWithResult(futureNodeResult{node: &restic.Node{
|
||||
Name: "child",
|
||||
Size: 42,
|
||||
}}))
|
||||
}
|
||||
|
||||
fb := b.Save(ctx, join("/", node.Name), node.Name, node, nodes, nil)
|
||||
fb.take(ctx)
|
||||
|
||||
err := shutdown()
|
||||
if identicalNodes {
|
||||
test.Assert(t, err == nil, "unexpected error found: %v", err)
|
||||
} else {
|
||||
test.Assert(t, err != nil, "expected error not found")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user