@@ -713,15 +713,15 @@ func TestGetCommonParents(t *testing.T) {
713
713
t .Run ("empty input" , func (t * testing.T ) {
714
714
t .Parallel ()
715
715
var paths []string
716
- got , ignored := GetCommonParents (paths , 1 , opts )
716
+ got , ignored := GetCommonParents (paths , 1 , GetPathComponents , opts )
717
717
assert .Equal (t , len (ignored ), 0 )
718
718
assert .DeepEqual (t , got , ([]string )(nil ))
719
719
})
720
720
721
721
t .Run ("single path returns itself" , func (t * testing.T ) {
722
722
t .Parallel ()
723
723
paths := []string {"/a/b/c/d" }
724
- got , ignored := GetCommonParents (paths , 1 , opts )
724
+ got , ignored := GetCommonParents (paths , 1 , GetPathComponents , opts )
725
725
assert .Equal (t , len (ignored ), 0 )
726
726
expected := []string {paths [0 ]}
727
727
assert .DeepEqual (t , got , expected )
@@ -730,7 +730,7 @@ func TestGetCommonParents(t *testing.T) {
730
730
t .Run ("paths shorter than minComponents are ignored" , func (t * testing.T ) {
731
731
t .Parallel ()
732
732
paths := []string {"/a/b/c/d" , "/a/b/c/e" , "/a/b/f/g" , "/x/y" }
733
- got , ignored := GetCommonParents (paths , 4 , opts )
733
+ got , ignored := GetCommonParents (paths , 4 , GetPathComponents , opts )
734
734
assert .DeepEqual (t , ignored , map [string ]struct {}{"/x/y" : {}})
735
735
expected := []string {"/a/b/c" , "/a/b/f/g" }
736
736
assert .DeepEqual (t , got , expected )
@@ -739,7 +739,7 @@ func TestGetCommonParents(t *testing.T) {
739
739
t .Run ("three paths share /a/b" , func (t * testing.T ) {
740
740
t .Parallel ()
741
741
paths := []string {"/a/b/c/d" , "/a/b/c/e" , "/a/b/f/g" }
742
- got , ignored := GetCommonParents (paths , 1 , opts )
742
+ got , ignored := GetCommonParents (paths , 1 , GetPathComponents , opts )
743
743
assert .Equal (t , len (ignored ), 0 )
744
744
expected := []string {"/a/b" }
745
745
assert .DeepEqual (t , got , expected )
@@ -748,7 +748,7 @@ func TestGetCommonParents(t *testing.T) {
748
748
t .Run ("mixed with short path collapses to root when minComponents=1" , func (t * testing.T ) {
749
749
t .Parallel ()
750
750
paths := []string {"/a/b/c/d" , "/a/b/c/e" , "/a/b/f/g" , "/x/y/z" }
751
- got , ignored := GetCommonParents (paths , 1 , opts )
751
+ got , ignored := GetCommonParents (paths , 1 , GetPathComponents , opts )
752
752
assert .Equal (t , len (ignored ), 0 )
753
753
expected := []string {"/" }
754
754
assert .DeepEqual (t , got , expected )
@@ -757,7 +757,7 @@ func TestGetCommonParents(t *testing.T) {
757
757
t .Run ("mixed with short path preserves both when minComponents=3" , func (t * testing.T ) {
758
758
t .Parallel ()
759
759
paths := []string {"/a/b/c/d" , "/a/b/c/e" , "/a/b/f/g" , "/x/y/z" }
760
- got , ignored := GetCommonParents (paths , 3 , opts )
760
+ got , ignored := GetCommonParents (paths , 3 , GetPathComponents , opts )
761
761
assert .Equal (t , len (ignored ), 0 )
762
762
expected := []string {"/a/b" , "/x/y/z" }
763
763
assert .DeepEqual (t , got , expected )
@@ -766,7 +766,7 @@ func TestGetCommonParents(t *testing.T) {
766
766
t .Run ("different volumes are returned individually" , func (t * testing.T ) {
767
767
t .Parallel ()
768
768
paths := []string {"c:/a/b/c/d" , "d:/a/b/c/d" }
769
- got , ignored := GetCommonParents (paths , 1 , opts )
769
+ got , ignored := GetCommonParents (paths , 1 , GetPathComponents , opts )
770
770
assert .Equal (t , len (ignored ), 0 )
771
771
expected := []string {paths [0 ], paths [1 ]}
772
772
assert .DeepEqual (t , got , expected )
@@ -775,7 +775,7 @@ func TestGetCommonParents(t *testing.T) {
775
775
t .Run ("duplicate paths deduplicate result" , func (t * testing.T ) {
776
776
t .Parallel ()
777
777
paths := []string {"/a/b/c/d" , "/a/b/c/d" }
778
- got , ignored := GetCommonParents (paths , 1 , opts )
778
+ got , ignored := GetCommonParents (paths , 1 , GetPathComponents , opts )
779
779
assert .Equal (t , len (ignored ), 0 )
780
780
expected := []string {paths [0 ]}
781
781
assert .DeepEqual (t , got , expected )
@@ -784,7 +784,7 @@ func TestGetCommonParents(t *testing.T) {
784
784
t .Run ("paths with few components are returned as-is when minComponents met" , func (t * testing.T ) {
785
785
t .Parallel ()
786
786
paths := []string {"/a/b/c/d" , "/x/y" }
787
- got , ignored := GetCommonParents (paths , 2 , opts )
787
+ got , ignored := GetCommonParents (paths , 2 , GetPathComponents , opts )
788
788
assert .Equal (t , len (ignored ), 0 )
789
789
expected := []string {"/a/b/c/d" , "/x/y" }
790
790
assert .DeepEqual (t , got , expected )
@@ -793,7 +793,7 @@ func TestGetCommonParents(t *testing.T) {
793
793
t .Run ("minComponents=2" , func (t * testing.T ) {
794
794
t .Parallel ()
795
795
paths := []string {"/a/b/c/d" , "/a/z/c/e" , "/a/aaa/f/g" , "/x/y/z" }
796
- got , ignored := GetCommonParents (paths , 2 , opts )
796
+ got , ignored := GetCommonParents (paths , 2 , GetPathComponents , opts )
797
797
assert .Equal (t , len (ignored ), 0 )
798
798
expected := []string {"/a" , "/x/y/z" }
799
799
assert .DeepEqual (t , got , expected )
@@ -802,7 +802,7 @@ func TestGetCommonParents(t *testing.T) {
802
802
t .Run ("trailing separators are handled" , func (t * testing.T ) {
803
803
t .Parallel ()
804
804
paths := []string {"/a/b/" , "/a/b/c" }
805
- got , ignored := GetCommonParents (paths , 1 , opts )
805
+ got , ignored := GetCommonParents (paths , 1 , GetPathComponents , opts )
806
806
assert .Equal (t , len (ignored ), 0 )
807
807
expected := []string {"/a/b" }
808
808
assert .DeepEqual (t , got , expected )
0 commit comments