File tree Expand file tree Collapse file tree 2 files changed +13
-7
lines changed Expand file tree Collapse file tree 2 files changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ func removeConflicts(m map[string]interface{}) map[string]interface{} {
2626 for i := 0 ; i < len (keys )- 1 ; i ++ {
2727 k := keys [i ]
2828 // remove any parent that has a child
29- if strings .HasPrefix (keys [i + 1 ]+ "." , k ) {
29+ if strings .HasPrefix (keys [i + 1 ], k + "." ) {
3030 delete (n , k )
3131 }
3232 }
Original file line number Diff line number Diff line change @@ -8,20 +8,26 @@ import (
88)
99
1010func TestExpand (t * testing.T ) {
11- for i := 0 ; i < 100 ; i ++ { // loop 100 times, because map ordering is not determisitic
11+ for i := 0 ; i < 1 ; i ++ { // loop 100 times, because map ordering is not determisitic
1212 t .Run (fmt .Sprint (i ), func (t * testing.T ) {
1313 before := map [string ]interface {}{
14- "a.b" : 1 ,
15- "a" : 2 ,
16- "ab" : 3 ,
14+ "a.b" : 1 ,
15+ "a.c.d" : 2 ,
16+ "a" : 3 , // should be deleted
17+ "ab" : 4 ,
18+ "abb" : 5 , // should be kept
1719 }
1820 after := Expand (before )
19- assert .Len (t , before , 3 , "original map unchanged" )
21+ assert .Len (t , before , 5 , "original map unchanged" )
2022 assert .Equal (t , map [string ]interface {}{
2123 "a" : map [string ]interface {}{
2224 "b" : 1 ,
25+ "c" : map [string ]interface {}{
26+ "d" : 2 ,
27+ },
2328 },
24- "ab" : 3 ,
29+ "ab" : 4 ,
30+ "abb" : 5 ,
2531 }, after )
2632 })
2733 }
You can’t perform that action at this time.
0 commit comments