Precompute each choice's shared paths so a dotted path stays O(1)
This commit is contained in:
committed by
lilleman-tw
parent
af5b8c9abd
commit
1665b37cad
+3
-4
@@ -15,11 +15,13 @@ func TestList(t *testing.T) {
|
||||
"person": `{"format":"{first} {last}","first":["A"],"last":["B"]}`,
|
||||
"word": `["x", "y"]`,
|
||||
"geo/city": `["Z"]`,
|
||||
// A bound {..path} reference is a render edge, not an addressable field.
|
||||
"greeting": `{"format":"hej {..person.first} and {own}","own":["x"]}`,
|
||||
// Only the fields every variant carries are addressable, so "extra" is not.
|
||||
"coin": `[{"format":"{code}","code":["A"],"name":["Aa"]},{"format":"{code}","code":["B"],"name":["Bb"],"extra":["x"]}]`,
|
||||
})
|
||||
got := newFakes(t, dir, WithSeed(1)).List()
|
||||
want := []string{"coin", "coin.code", "coin.name", "geo.city", "person", "person.first", "person.last", "word"}
|
||||
want := []string{"coin", "coin.code", "coin.name", "geo.city", "greeting", "greeting.own", "person", "person.first", "person.last", "word"}
|
||||
if !reflect.DeepEqual(got, want) {
|
||||
t.Fatalf("List() = %v, want %v", got, want)
|
||||
}
|
||||
@@ -141,9 +143,6 @@ func TestMultiPathMergesFolders(t *testing.T) {
|
||||
func TestListedPathsAllRender(t *testing.T) {
|
||||
f := newFakes(t, "data", WithSeed(4))
|
||||
paths := f.List()
|
||||
if len(paths) < 50 {
|
||||
t.Fatalf("List() = %d paths, want the whole shipped tree", len(paths))
|
||||
}
|
||||
for _, p := range paths {
|
||||
for i := 0; i < 20; i++ {
|
||||
if _, err := f.Fake(p); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user