Test openapi schema of route /workgroup/*
add test and fix update workgroup
This commit is contained in:
@@ -16,6 +16,7 @@ import integration.steps.given.`Given I have workgroup`
|
||||
import integration.steps.given.`With members`
|
||||
import integration.steps.given.`authenticated as`
|
||||
import integration.steps.given.`with no content`
|
||||
import integration.steps.then.`And have property`
|
||||
import io.ktor.http.HttpStatusCode.Companion.Created
|
||||
import io.ktor.http.HttpStatusCode.Companion.NoContent
|
||||
import io.ktor.http.HttpStatusCode.Companion.NotFound
|
||||
@@ -88,6 +89,47 @@ class `Workgroup routes` : BaseTest() {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `I can edit a workgroup`() {
|
||||
withIntegrationApplication {
|
||||
`Given I have citizen`("John", "Wheeler")
|
||||
`Given I have citizen`("Heinrich", "Hertz", id = "94f92424-c257-4582-907c-98564a8c4ac9")
|
||||
`Given I have citizen`("William", "Thomson", id = "87909ba3-2069-431c-9924-219fd8411cf2")
|
||||
`Given I have workgroup`("aa875a24-0050-4252-9130-d37391714e26", createdBy = Name("John", "Wheeler")) {
|
||||
`With members`(
|
||||
Name("Heinrich", "Hertz"),
|
||||
Name("William", "Thomson"),
|
||||
)
|
||||
}
|
||||
`When I send a PUT request`("/workgroups/aa875a24-0050-4252-9130-d37391714e26") {
|
||||
`authenticated as`("John", "Wheeler")
|
||||
`with body`("""
|
||||
{
|
||||
"name":"La ratatouille",
|
||||
"description":"Une petite souris"
|
||||
}
|
||||
""")
|
||||
} `Then the response should be` OK and {
|
||||
`And the response should contain`("$.id", "aa875a24-0050-4252-9130-d37391714e26")
|
||||
`And the response should contain`("$.name", "La ratatouille")
|
||||
`And the response should contain`("$.description", "Une petite souris")
|
||||
|
||||
`And have property`("$.members")
|
||||
`And the response should contain list`("$.members", 3, 3)
|
||||
`And the response should contain`("$.members.[1]citizen.id", "94f92424-c257-4582-907c-98564a8c4ac9")
|
||||
`And the response should contain`("$.members.[2]citizen.id", "87909ba3-2069-431c-9924-219fd8411cf2")
|
||||
}
|
||||
|
||||
`When I send a GET request`("/workgroups/aa875a24-0050-4252-9130-d37391714e26") {
|
||||
`authenticated as`("John", "Wheeler")
|
||||
} `Then the response should be` OK and {
|
||||
`And the response should contain`("$.id", "aa875a24-0050-4252-9130-d37391714e26")
|
||||
`And the response should contain`("$.name", "La ratatouille")
|
||||
`And the response should contain`("$.description", "Une petite souris")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `I can delete a workgroup`() {
|
||||
withIntegrationApplication {
|
||||
|
||||
@@ -9,6 +9,11 @@ declare
|
||||
"description": "test",
|
||||
"anonymous": false
|
||||
}';
|
||||
created_workgroup_updated json := '{
|
||||
"name": "Le groupe des rouge",
|
||||
"description": "red",
|
||||
"anonymous": false
|
||||
}';
|
||||
created_workgroup_2 json := '{
|
||||
"name": "hello",
|
||||
"description": "super",
|
||||
@@ -22,12 +27,19 @@ begin
|
||||
created_workgroup := jsonb_set(created_workgroup::jsonb, '{created_by}'::text[], jsonb_build_object('id', _citizen_id::text), true)::json;
|
||||
assert created_workgroup#>>'{created_by, id}' = _citizen_id::text, format('citizenId in workgroup must be the same as citizen, %s != %s', created_workgroup#>>'{created_by, id}', _citizen_id::text);
|
||||
|
||||
-- upsert workgroup
|
||||
-- insert workgroup
|
||||
select upsert_workgroup(created_workgroup) into created_workgroup;
|
||||
assert created_workgroup->>'description' is not null, 'description should not be null';
|
||||
assert (created_workgroup->>'name') = 'Le groupe des vert', format('name must be equal to "Le groupe des vert", %s instead', created_workgroup->>'name');
|
||||
assert (created_workgroup#>>'{members, 0, citizen, id}') = _citizen_id::text, 'workgroup must have creator in members on creation';
|
||||
|
||||
-- update workgroup
|
||||
created_workgroup_updated := jsonb_set(created_workgroup_updated::jsonb, '{created_by}'::text[], jsonb_build_object('id', _citizen_id::text), true)::json;
|
||||
select upsert_workgroup(created_workgroup_updated) into created_workgroup_updated;
|
||||
assert created_workgroup_updated->>'description' is not null, 'description should not be null';
|
||||
assert (created_workgroup_updated->>'name') = 'Le groupe des rouge', format('name must be equal to "Le groupe des rouge", %s instead', created_workgroup_updated->>'name');
|
||||
assert (created_workgroup_updated#>>'{members, 0, citizen, id}') = _citizen_id::text, 'workgroup must have creator in members on update';
|
||||
|
||||
-- insert another workgroup
|
||||
created_workgroup_2 := jsonb_set(created_workgroup_2::jsonb, '{created_by}'::text[], jsonb_build_object('id', _citizen_id::text), true)::json;
|
||||
assert created_workgroup_2#>>'{created_by, id}' = _citizen_id::text, format('citizenId in workgroup must be the same as citizen, %s != %s', created_workgroup_2#>>'{created_by, id}', _citizen_id::text);
|
||||
|
||||
Reference in New Issue
Block a user