Skip to content

Commit ff16788

Browse files
committed
add some ifvalue tests and error checks
Signed-off-by: Doug Davis <[email protected]>
1 parent fc03628 commit ff16788

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

README.md

-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ TODOs:
140140
- multi-delete must ignore all attributes except id and epoch
141141
- fix init.sql, it's too slow due to latest xref stuff in commit 9c583e7
142142
- add support for inline=endpoints.*
143-
- ban the use of ^ in ifvalue VALUES for now
144143
- support ETag/If-Match
145144
- update epoch/modifiedat of parent when nested entity is added/removed
146145
- ?nested isn't needed to update `model` or `meta` attributes

registry/model.go

+5
Original file line numberDiff line numberDiff line change
@@ -2390,6 +2390,11 @@ func (attrs Attributes) Verify(ld *LevelData) error {
23902390
return fmt.Errorf("%q has an empty ifvalues key", ld.Path.UI())
23912391
}
23922392

2393+
if valStr[0] == '^' {
2394+
return fmt.Errorf("%q has an ifvalues key that starts "+
2395+
"with \"^\"", ld.Path.UI())
2396+
}
2397+
23932398
nextLD := &LevelData{
23942399
ld.Model,
23952400
ld.AttrNames,

tests/http1_test.go

+18
Original file line numberDiff line numberDiff line change
@@ -4919,6 +4919,24 @@ func TestHTTPIfValue(t *testing.T) {
49194919
})
49204920
xCheckErr(t, err, "")
49214921

4922+
_, err = reg.Model.AddAttribute(&registry.Attribute{
4923+
Name: "badone",
4924+
Type: registry.INTEGER,
4925+
IfValues: registry.IfValues{
4926+
"": &registry.IfValue{},
4927+
},
4928+
})
4929+
xCheckErr(t, err, "\"model\" has an empty ifvalues key")
4930+
4931+
_, err = reg.Model.AddAttribute(&registry.Attribute{
4932+
Name: "badone",
4933+
Type: registry.INTEGER,
4934+
IfValues: registry.IfValues{
4935+
"^6": &registry.IfValue{},
4936+
},
4937+
})
4938+
xCheckErr(t, err, "\"model\" has an ifvalues key that starts with \"^\"")
4939+
49224940
xCheckHTTP(t, reg, &HTTPTest{
49234941
Name: "PUT reg - ifvalue - 1",
49244942
URL: "",

0 commit comments

Comments
 (0)