improvements and fixing of the tests

This commit is contained in:
filipriec
2025-06-20 19:59:42 +02:00
parent 8414657224
commit 8e22ea05ff
4 changed files with 87 additions and 42 deletions

View File

@@ -173,26 +173,24 @@ async fn test_fail_on_true_self_referential_link(#[future] pool: PgPool) {
#[tokio::test]
async fn test_behavior_on_empty_profile_name(#[future] pool: PgPool) {
// Scenario: Attempt to create a table with an empty profile name.
// Expected: This should violate the database's NOT NULL constraint on profiles.name.
// Expected: This should be rejected by input validation.
let pool = pool.await;
let request = PostTableDefinitionRequest {
profile_name: "".into(),
table_name: "table_in_empty_profile".into(),
..Default::default()
};
// Act
let result = post_table_definition(&pool, request).await;
// Assert
let err = result.unwrap_err();
assert_eq!(
err.code(),
Code::Internal,
"Expected Internal error from DB constraint violation"
Code::InvalidArgument, // Changed from Internal
"Expected InvalidArgument error from input validation"
);
assert!(
err.message().to_lowercase().contains("profile error"),
err.message().contains("Profile name cannot be empty"), // Updated message
"Unexpected error message: {}",
err.message()
);