diff --git a/bound_test.go b/bound_test.go index 6b0468b..fc68936 100644 --- a/bound_test.go +++ b/bound_test.go @@ -656,12 +656,13 @@ func TestDeepPathsUnderOneHeadStayIndependentWhereTheyDiverge(t *testing.T) { } func TestEmptyPathSegmentIsRejected(t *testing.T) { - // "{a.}", "{.b}" and "{a..b}" are unfinished paths. A field really named "" - // would otherwise make them resolve, which reads as a typo that worked. + // "{a.}", "{.b}" and "{a..b}" are unfinished paths, and the segment naming + // nothing is reported as that rather than as a missing field. An empty name is + // rejected where it is authored, so no data can make these resolve. rejected := map[string]string{ - "trailing dot": `{"format":"[{a.}]","a":{"format":"x","":["V"]}}`, - "leading dot": `{"format":"[{.b}]","":{"format":"{b}","b":["V"]}}`, - "double dot": `{"format":"[{a..b}]","a":{"format":"x","":{"format":"{b}","b":["V"]}}}`, + "trailing dot": `{"format":"[{a.}]","a":{"format":"x"}}`, + "leading dot": `{"format":"[{.b}]","a":{"format":"{b}","b":["V"]}}`, + "double dot": `{"format":"[{a..b}]","a":{"format":"x"}}`, } for name, file := range rejected { _, err := New([]string{writeData(t, map[string]string{"cat": file})}) diff --git a/edge_test.go b/edge_test.go index 806416c..2ee4eb9 100644 --- a/edge_test.go +++ b/edge_test.go @@ -120,6 +120,13 @@ func TestNewErrors(t *testing.T) { map[string]string{"a|b": `["1"]`}, `category "a|b" contains "|"`, }, + // An empty name is reachable by no dot path, so List cannot advertise it and + // Fake cannot ask for it — {} is the one spelling that reaches it, which is + // the same trap {a.} is already rejected for. + "empty field name": { + map[string]string{"a": `{"format":"[{}]","":"VALUE"}`}, + `field "" is empty`, + }, "folder name with a paren": { map[string]string{"a(b/cat": `["1"]`}, `folder "a(b" contains "("`,