@@ -6621,52 +6621,78 @@ func TestHasRootsOverlap(t *testing.T) {
66216621 ctx := context .Background ()
66226622
66236623 cases := []struct {
6624- note string
6625- storeRoots map [string ]* []string
6626- bundleRoots map [string ]* []string
6627- overlaps bool
6624+ note string
6625+ storeRoots map [string ]* []string
6626+ newBundleRoots map [string ]* []string
6627+ expectedError string
66286628 }{
66296629 {
6630- note : "no overlap with existing roots" ,
6631- storeRoots : map [string ]* []string {"bundle1" : {"a" , "b" }},
6632- bundleRoots : map [string ]* []string {"bundle2" : {"c" }},
6633- overlaps : false ,
6630+ note : "no overlap between store and new bundles" ,
6631+ storeRoots : map [string ]* []string {"bundle1" : {"a" , "b" }},
6632+ newBundleRoots : map [string ]* []string {"bundle2" : {"c" }},
6633+ },
6634+ {
6635+ note : "no overlap between store and multiple new bundles" ,
6636+ storeRoots : map [string ]* []string {"bundle1" : {"a" , "b" }},
6637+ newBundleRoots : map [string ]* []string {"bundle2" : {"c" }, "bundle3" : {"d" }},
6638+ },
6639+ {
6640+ note : "no overlap with empty store" ,
6641+ storeRoots : map [string ]* []string {},
6642+ newBundleRoots : map [string ]* []string {"bundle1" : {"a" , "b" }},
6643+ },
6644+ {
6645+ note : "no overlap between multiple new bundles with empty store" ,
6646+ storeRoots : map [string ]* []string {},
6647+ newBundleRoots : map [string ]* []string {"bundle1" : {"a" , "b" }, "bundle2" : {"c" }},
6648+ },
6649+ {
6650+ note : "overlap between multiple new bundles with empty store" ,
6651+ storeRoots : map [string ]* []string {},
6652+ newBundleRoots : map [string ]* []string {"bundle1" : {"a" , "b" }, "bundle2" : {"a" , "c" }},
6653+ expectedError : "detected overlapping roots in manifests for these bundles: [bundle1, bundle2] (root a is in multiple bundles)" ,
66346654 },
66356655 {
6636- note : "no overlap with existing roots multiple bundles " ,
6637- storeRoots : map [string ]* []string {"bundle1" : {"a" , "b" }},
6638- bundleRoots : map [string ]* []string {"bundle2" : {"c" } , "bundle3" : { "d " }},
6639- overlaps : false ,
6656+ note : " overlap between store and new bundle " ,
6657+ storeRoots : map [string ]* []string {"bundle1" : {"a" , "b" }},
6658+ newBundleRoots : map [string ]* []string {"bundle2" : {"c" , "a " }},
6659+ expectedError : "detected overlapping roots in manifests for these bundles: [bundle1, bundle2] (root a is in multiple bundles)" ,
66406660 },
66416661 {
6642- note : "no overlap no existing roots " ,
6643- storeRoots : map [string ]* []string {},
6644- bundleRoots : map [string ]* []string {"bundle1 " : {"a" , "b " }},
6645- overlaps : false ,
6662+ note : " overlap between store and multiple new bundles " ,
6663+ storeRoots : map [string ]* []string {"bundle1" : { "a" , "b" } },
6664+ newBundleRoots : map [string ]* []string {"bundle2 " : {"c" , "a" } , "bundle3" : { "a " }},
6665+ expectedError : "detected overlapping roots in manifests for these bundles: [bundle1, bundle2, bundle3] (root a is in multiple bundles)" ,
66466666 },
66476667 {
6648- note : "no overlap without existing roots multiple bundles " ,
6649- storeRoots : map [string ]* []string {},
6650- bundleRoots : map [string ]* []string {"bundle1" : { "a" , "b" }, " bundle2" : {"c " }},
6651- overlaps : false ,
6668+ note : " overlap between store bundle and new empty root bundle " ,
6669+ storeRoots : map [string ]* []string {"bundle1" : { "a" , "b" } },
6670+ newBundleRoots : map [string ]* []string {"bundle2" : {"" }},
6671+ expectedError : "bundles [bundle1, bundle2] have overlapping roots and cannot be activated simultaneously because bundle(s) [bundle2] specify empty root paths ('') which overlap with any other bundle root" ,
66526672 },
66536673 {
6654- note : "overlap without existing roots multiple bundles" ,
6655- storeRoots : map [string ]* []string {},
6656- bundleRoots : map [string ]* []string {"bundle1" : {"a" , "b" }, "bundle2" : {"a" , "c " }},
6657- overlaps : true ,
6674+ note : "overlap between multiple new empty root bundles" ,
6675+ storeRoots : map [string ]* []string {},
6676+ newBundleRoots : map [string ]* []string {"bundle1" : {"" }, "bundle2" : {"" }},
6677+ expectedError : "bundles [bundle1, bundle2] have overlapping roots and cannot be activated simultaneously because bundle(s) [bundle1, bundle2] specify empty root paths ('') which overlap with any other bundle root" ,
66586678 },
66596679 {
6660- note : "overlap with existing roots " ,
6661- storeRoots : map [string ]* []string {"bundle1" : { "a" , "b" } },
6662- bundleRoots : map [string ]* []string {"bundle2 " : {"c" , "a " }},
6663- overlaps : true ,
6680+ note : "overlap between new empty root and new regular root bundles " ,
6681+ storeRoots : map [string ]* []string {},
6682+ newBundleRoots : map [string ]* []string {"bundle1 " : {"a" } , "bundle2" : { " " }},
6683+ expectedError : "bundles [bundle1, bundle2] have overlapping roots and cannot be activated simultaneously because bundle(s) [bundle2] specify empty root paths ('') which overlap with any other bundle root" ,
66646684 },
66656685 {
6666- note : "overlap with existing roots multiple bundles" ,
6667- storeRoots : map [string ]* []string {"bundle1" : {"a" , "b" }},
6668- bundleRoots : map [string ]* []string {"bundle2" : {"c" , "a" }, "bundle3" : {"a" }},
6669- overlaps : true ,
6686+ note : "overlap between nested paths" ,
6687+ storeRoots : map [string ]* []string {},
6688+ newBundleRoots : map [string ]* []string {"bundle1" : {"a" }, "bundle2" : {"a/b" }},
6689+ expectedError : "detected overlapping roots in manifests for these bundles: [bundle1, bundle2] (a overlaps a/b)" ,
6690+ },
6691+ {
6692+ note : "overlap between store nested path and new bundle path" ,
6693+ storeRoots : map [string ]* []string {"bundle1" : {"a/b" }},
6694+ newBundleRoots : map [string ]* []string {"bundle2" : {"a" }},
6695+ expectedError : "detected overlapping roots in manifests for these bundles: [bundle1, bundle2] (a overlaps a/b)" ,
66706696 },
66716697 }
66726698
@@ -6683,7 +6709,7 @@ func TestHasRootsOverlap(t *testing.T) {
66836709 }
66846710
66856711 bundles := map [string ]* Bundle {}
6686- for name , roots := range tc .bundleRoots {
6712+ for name , roots := range tc .newBundleRoots {
66876713 bundles [name ] = & Bundle {
66886714 Manifest : Manifest {
66896715 Roots : roots ,
@@ -6692,10 +6718,15 @@ func TestHasRootsOverlap(t *testing.T) {
66926718 }
66936719
66946720 err := hasRootsOverlap (ctx , mockStore , txn , bundles )
6695- if ! tc .overlaps && err != nil {
6696- t .Fatalf ("unepected error: %s" , err )
6697- } else if tc .overlaps && (err == nil || ! strings .Contains (err .Error (), "detected overlapping roots in bundle manifest" )) {
6698- t .Fatalf ("expected overlapping roots error, got: %s" , err )
6721+ if tc .expectedError != "" {
6722+ if err == nil {
6723+ t .Fatalf ("expected error %q, got nil" , tc .expectedError )
6724+ }
6725+ if err .Error () != tc .expectedError {
6726+ t .Fatalf ("expected error message %q, got %q" , tc .expectedError , err .Error ())
6727+ }
6728+ } else if err != nil {
6729+ t .Fatalf ("unexpected error: %s" , err )
66996730 }
67006731
67016732 err = mockStore .Commit (ctx , txn )
0 commit comments