diff options
| author | Owen Jacobson <owen@grimoire.ca> | 2024-10-19 00:57:20 -0400 |
|---|---|---|
| committer | Owen Jacobson <owen@grimoire.ca> | 2024-10-19 00:57:20 -0400 |
| commit | ad00b553d845dba8af7b0e9fa2930209aee1dd62 (patch) | |
| tree | 0a91c3c0113b2618730d3160f311c083e95b0581 /src/test/fixtures/login.rs | |
| parent | 635d92eb4ffc5a1c94cba784a2a4f18e1cb5effc (diff) | |
Make the responses for various data creation requests more consistent.
In general:
* If the client can only assume the response is immediately valid (mostly, login creation, where the client cannot monitor the event stream), then 200 Okay, with data describing the server's view of the request.
* If the client can monitor for completion by watching the event stream, then 202 Accepted, with data describing the server's view of the request.
This comes on the heels of a comment I made on Discord:
> hrm
>
> creating a login: 204 No Content, no body
> sending a message: 202 Accepted, no body
> creating a channel: 200 Okay, has a body
>
> past me, what were you on
There wasn't any principled reason for this inconsistency; it happened as the endpoints were written at different times and with different states of mind.
Diffstat (limited to 'src/test/fixtures/login.rs')
| -rw-r--r-- | src/test/fixtures/login.rs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/test/fixtures/login.rs b/src/test/fixtures/login.rs index e5ac716..b6766fe 100644 --- a/src/test/fixtures/login.rs +++ b/src/test/fixtures/login.rs @@ -7,14 +7,15 @@ use crate::{ login::{self, Login, Password}, }; -pub async fn create_with_password(app: &App, created_at: &RequestedAt) -> (String, Password) { +pub async fn create_with_password(app: &App, created_at: &RequestedAt) -> (Login, Password) { let (name, password) = propose(); - app.logins() + let login = app + .logins() .create(&name, &password, created_at) .await .expect("should always succeed if the login is actually new"); - (name, password) + (login, password) } pub async fn create(app: &App, created_at: &RequestedAt) -> Login { |
