Skip to content

Commit

Permalink
Change the test from a username too short to a username too long
Browse files Browse the repository at this point in the history
  • Loading branch information
sandhose committed Dec 19, 2024
1 parent 551beb0 commit 1dfda93
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions crates/handlers/src/views/register.rs
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ mod tests {
}

#[sqlx::test(migrator = "mas_storage_pg::MIGRATOR")]
async fn test_register_username_too_short(pool: PgPool) {
async fn test_register_username_too_long(pool: PgPool) {
setup();
let state = TestState::from_pool(pool).await.unwrap();
let cookies = CookieHelper::new();
Expand All @@ -524,7 +524,7 @@ mod tests {
let request = Request::post(&*mas_router::Register::default().path_and_query()).form(
serde_json::json!({
"csrf": csrf_token,
"username": "",
"username": "a".repeat(256),
"email": "[email protected]",
"password": "hunter2",
"password_confirm": "hunter2",
Expand All @@ -535,7 +535,11 @@ mod tests {
let response = state.request(request).await;
cookies.save_cookies(&response);
response.assert_status(StatusCode::OK);
assert!(response.body().contains("username too short"));
assert!(
response.body().contains("Username is too long"),
"response body: {}",
response.body()
);
}

/// When the user already exists in the database, it should give an error
Expand Down

0 comments on commit 1dfda93

Please sign in to comment.