use athena_rs::api::gateway::update::table_id_map::{
    find_closest_uuid_column, get_resource_id_key,
};

#[tokio::test]
async fn returns_user_id_for_users_table() {
    assert_eq!(get_resource_id_key("users").await, "user_id");
}

#[tokio::test]
async fn defaults_to_id_when_unknown_table() {
    let result = get_resource_id_key("abracadabra_table").await;
    assert!(result == "id" || !result.is_empty());
}

#[test]
fn test_find_closest_uuid_column() {
    let table_name = "users";
    let uuid_columns = vec![
        "user_id".to_string(),
        "company_id".to_string(),
        "organization_id".to_string(),
    ];

    let result = find_closest_uuid_column(table_name, &uuid_columns);
    assert_eq!(result, Some("user_id".to_string()));
}

#[test]
fn test_find_closest_uuid_column_with_similar_names() {
    let table_name = "invoices";
    let uuid_columns = vec![
        "invoice_id".to_string(),
        "user_id".to_string(),
        "company_id".to_string(),
    ];

    let result = find_closest_uuid_column(table_name, &uuid_columns);
    assert_eq!(result, Some("invoice_id".to_string()));
}

#[test]
fn test_find_closest_uuid_column_empty() {
    let table_name = "users";
    let uuid_columns: Vec<String> = vec![];

    let result = find_closest_uuid_column(table_name, &uuid_columns);
    assert_eq!(result, None);
}
