more fixes
This commit is contained in:
@@ -246,26 +246,44 @@ async fn test_nullable_and_multiple_links(#[future] pool_with_preexisting_table:
|
||||
// 8) Duplicate links in one request → Internal.
|
||||
#[rstest]
|
||||
#[tokio::test]
|
||||
async fn test_fail_on_duplicate_links(#[future] pool_with_preexisting_table: PgPool) {
|
||||
let pool = pool_with_preexisting_table.await;
|
||||
async fn test_fail_on_duplicate_links(#[future] pool: PgPool) {
|
||||
let pool = pool.await;
|
||||
let unique_id = std::time::SystemTime::now()
|
||||
.duration_since(std::time::UNIX_EPOCH)
|
||||
.unwrap()
|
||||
.as_nanos();
|
||||
let customers_table = format!("customers_{}", unique_id);
|
||||
|
||||
// Create the prerequisite table
|
||||
let prereq_req = PostTableDefinitionRequest {
|
||||
profile_name: "default".into(),
|
||||
table_name: customers_table.clone(),
|
||||
columns: vec![],
|
||||
links: vec![],
|
||||
indexes: vec![],
|
||||
};
|
||||
post_table_definition(&pool, prereq_req).await.expect("Failed to create prerequisite table");
|
||||
|
||||
// Now, test the duplicate link scenario
|
||||
let req = PostTableDefinitionRequest {
|
||||
profile_name: "default".into(),
|
||||
table_name: "dup_links".into(),
|
||||
table_name: format!("dup_links_{}", unique_id),
|
||||
columns: vec![],
|
||||
indexes: vec![],
|
||||
links: vec![
|
||||
TableLink {
|
||||
linked_table_name: "customers".into(),
|
||||
linked_table_name: customers_table.clone(),
|
||||
required: true,
|
||||
},
|
||||
TableLink {
|
||||
linked_table_name: "customers".into(),
|
||||
linked_table_name: customers_table.clone(),
|
||||
required: false,
|
||||
},
|
||||
],
|
||||
};
|
||||
let err = post_table_definition(&pool, req).await.unwrap_err();
|
||||
assert_eq!(err.code(), Code::Internal);
|
||||
assert_eq!(err.code(), Code::InvalidArgument);
|
||||
assert!(err.message().contains(&format!("Duplicate link to table '{}'", customers_table)));
|
||||
}
|
||||
|
||||
// 9) Self‐referential FK: link child back to same‐profile parent.
|
||||
|
||||
Reference in New Issue
Block a user