write tests to check username validation

This commit is contained in:
bitfl0wer 2023-04-16 12:30:30 +02:00
parent 30610aacfd
commit b8038f52bf
1 changed files with 35 additions and 0 deletions

View File

@ -160,4 +160,39 @@ mod schemas_tests {
}) })
); );
} }
#[test]
fn username_too_short() {
assert_eq!(
RegisterSchema::new(
"T".to_string(),
None,
true,
None,
None,
None,
None,
None,
None,
None,
),
Err(RegisterSchemaError {
message: "Username must be between 2 and 32 characters".to_string()
})
);
}
#[test]
fn username_too_long() {
let mut long_un = String::new();
for _ in 0..33 {
long_un = long_un + "a";
}
assert_eq!(
RegisterSchema::new(long_un, None, true, None, None, None, None, None, None, None,),
Err(RegisterSchemaError {
message: "Username must be between 2 and 32 characters".to_string()
})
);
}
} }