diff options
| author | Owen Jacobson <owen@grimoire.ca> | 2024-10-29 20:44:03 -0400 |
|---|---|---|
| committer | Owen Jacobson <owen@grimoire.ca> | 2024-10-29 20:44:03 -0400 |
| commit | 9010c7feeca8f4e7e501ad474911deaaf7a1a367 (patch) | |
| tree | e2fb736e7923c0d084ee3ebffe03752dc237edfb /src/channel/routes/test.rs | |
| parent | 15311c7bd816a83d0641de6b6bb3c41bb67079db (diff) | |
Restrict channel names, too.
Thankfully, channel creation only happens in one place, so we don't need a state machine for this.
Diffstat (limited to 'src/channel/routes/test.rs')
| -rw-r--r-- | src/channel/routes/test.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/channel/routes/test.rs b/src/channel/routes/test.rs index 10b1e8d..f5369fb 100644 --- a/src/channel/routes/test.rs +++ b/src/channel/routes/test.rs @@ -116,6 +116,30 @@ async fn conflicting_canonical_name() { } #[tokio::test] +async fn invalid_name() { + // Set up the environment + + let app = fixtures::scratch_app().await; + let creator = fixtures::identity::create(&app, &fixtures::now()).await; + + // Call the endpoint + + let name = fixtures::channel::propose_invalid_name(); + let request = post::Request { name: name.clone() }; + let post::Error(error) = + post::handler(State(app.clone()), creator, fixtures::now(), Json(request)) + .await + .expect_err("invalid channel name should fail the request"); + + // Verify the structure of the response + + assert!(matches!( + error, + app::CreateError::InvalidName(error_name) if name == error_name + )); +} + +#[tokio::test] async fn name_reusable_after_delete() { // Set up the environment |
