Skip to content

Commit

Permalink
more test tweaks
Browse files Browse the repository at this point in the history
Signed-off-by: Doug Davis <[email protected]>
  • Loading branch information
duglin committed Jan 10, 2025
1 parent 6aaf2fa commit fc03628
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ TODOs:
- support the DB vanishing for a while
- create an UpdateDefaultVersion func in resource.go to move it from http logic
- support ?export /export
- support ximport
- support validating that xref points to the same resource def
- test xref more
- in particular PATCH on an xref resource where body doesn't have xref
- testing doing a PUT/POST/PATCH on an xref - fail? ignore attrs?
Expand Down
11 changes: 10 additions & 1 deletion tests/xref_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,9 @@ func TestXrefRevert(t *testing.T) {

// Notice epoch will be 2 not 1 since it's max(0,fx.epoch)+1
// Notice meta.createat == f0's createdat, others are now()
// Make sure we pick up def ver attrs
xHTTP(t, reg, "PUT", "/dirs/d1/files/fx?inline=meta", `{
"description": "hello",
"meta":{"xref":null}
} `, 200, `{
"fileid": "fx",
Expand All @@ -640,6 +642,7 @@ func TestXrefRevert(t *testing.T) {
"xid": "/dirs/d1/files/fx",
"epoch": 1,
"isdefault": true,
"description": "hello",
"createdat": "2025-01-01T12:00:02Z",
"modifiedat": "2025-01-01T12:00:02Z",
Expand Down Expand Up @@ -764,7 +767,9 @@ func TestXrefRevert(t *testing.T) {
}
`)

// Notice "description:bye" is ignored
xHTTP(t, reg, "PUT", "/dirs/d1/files/fx?inline=meta&nested", `{
"description": "bye",
"meta":{"xref":null},
"versions": { "v1": { "description": "ver1" } }
} `, 200, `{
Expand Down Expand Up @@ -832,7 +837,9 @@ func TestXrefRevert(t *testing.T) {
}
`)

// "description:bye" is ignored
xHTTP(t, reg, "PUT", "/dirs/d1/files/fx?inline=meta&nested", `{
"description": "bye",
"meta":{"xref":null},
"versions": { "z1": {}, "a1": {} }
} `, 200, `{
Expand Down Expand Up @@ -899,6 +906,8 @@ func TestXrefRevert(t *testing.T) {
}
`)

// Not 100% this is legal per the spec, we should probably reject the
// query parameter since I think it's only allowed on 'POST /versions'
xHTTP(t, reg, "PUT", "/dirs/d1/files/fx?inline=meta&nested&setdefaultversionid=bb", `{
"meta":{"xref":null },
"versions": { "z2": {}, "b3": {} }
Expand Down Expand Up @@ -1035,7 +1044,7 @@ func TestXrefRevert(t *testing.T) {
}
`)

// defaultversionid is ignored
// defaultversionid is ignored because we're not sticky
xHTTP(t, reg, "PUT", "/dirs/d1/files/fx/meta",
`{"xref":null,
"defaultversionid": "bb"}`, 200, `{
Expand Down

0 comments on commit fc03628

Please sign in to comment.