Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
Signed-off-by: Doug Davis <[email protected]>
  • Loading branch information
duglin committed Dec 12, 2024
1 parent 89607d2 commit b9892ca
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 1 deletion.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,3 @@ TODOs:
- test clearing xref and setting defver attrs, via res and via meta directly
- test to ensure meta epoch changes as versions are added/removed
- test the timestamps in meta. Should change as versions are added/removed.
- test versionid as http header in resource create cases
71 changes: 71 additions & 0 deletions tests/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14043,3 +14043,74 @@ func TestHTTPRecursiveData(t *testing.T) {
`)

}

func TestHTTPDefVer(t *testing.T) {
reg := NewRegistry("TestHTTPDefVer")
defer PassDeleteReg(t, reg)
xCheck(t, reg != nil, "can't create reg")

gm, _ := reg.Model.AddGroupModel("dirs", "dir")
gm.AddResourceModelSimple("files", "file")

xCheckHTTP(t, reg, &HTTPTest{
Name: "PUT file + versionid header",
URL: "/dirs/d1/files/f1",
Method: "PUT",
ReqHeaders: []string{
`xRegistry-versionid: v1`,
},
ReqBody: `pick me`,
Code: 201,
HeaderMasks: []string{},
ResHeaders: []string{
"xRegistry-fileid: f1",
"xRegistry-versionid: v1",
"xRegistry-self: http://localhost:8181/dirs/d1/files/f1",
"xRegistry-epoch: 1",
"xRegistry-isdefault: true",
"xRegistry-createdat: 2024-01-01T12:00:01Z",
"xRegistry-modifiedat: 2024-01-01T12:00:01Z",
"xRegistry-metaurl: http://localhost:8181/dirs/d1/files/f1/meta",
"xRegistry-versionsurl: http://localhost:8181/dirs/d1/files/f1/versions",
"xRegistry-versionscount: 1",
"Content-Length: 7",
"Content-Location: http://localhost:8181/dirs/d1/files/f1/versions/v1",
"Content-Type: text/plain; charset=utf-8",
"Location: http://localhost:8181/dirs/d1/files/f1",
},
ResBody: `pick me`,
})

xCheckHTTP(t, reg, &HTTPTest{
Name: "POST file + versionid header",
URL: "/dirs/d1/files",
Method: "POST",
ReqBody: `{
"f2": {
"versionid": "v1"
}
}`,
Code: 200,
HeaderMasks: []string{},
ResHeaders: []string{
"Content-Type: application/json",
},
ResBody: `{
"f2": {
"fileid": "f2",
"versionid": "v1",
"self": "http://localhost:8181/dirs/d1/files/f2$structure",
"epoch": 1,
"isdefault": true,
"createdat": "2024-12-12T21:53:22.592492247Z",
"modifiedat": "2024-12-12T21:53:22.592492247Z",
"metaurl": "http://localhost:8181/dirs/d1/files/f2/meta",
"versionsurl": "http://localhost:8181/dirs/d1/files/f2/versions",
"versionscount": 1
}
}
`,
})

}

0 comments on commit b9892ca

Please sign in to comment.