#[cfg(test)]
mod tests {
    use dbnexus_cli::schema::{Schema, Table, Column};

    #[test]
    fn test_parse_schema() {
        let sql = "CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT, email TEXT);";
        let schema = Schema::from_sql(sql).unwrap();
        assert_eq!(schema.tables.len(), 1);
        assert_eq!(schema.tables.get("users").unwrap().name, "users");
    }

    #[test]
    fn test_parse_multiple_tables() {
        let sql = "CREATE TABLE users (id INTEGER PRIMARY KEY); CREATE TABLE posts (id INTEGER PRIMARY KEY);";
        let schema = Schema::from_sql(sql).unwrap();
        assert_eq!(schema.tables.len(), 2);
    }

    #[test]
    fn test_parse_columns() {
        let sql = "CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT NOT NULL, email TEXT);";
        let schema = Schema::from_sql(sql).unwrap();
        let table = schema.get_table("users").unwrap();
        assert_eq!(table.columns.len(), 3);
        assert_eq!(table.columns[0].name, "id");
        assert_eq!(table.columns[1].name, "name");
        assert_eq!(table.columns[2].name, "email");
    }

    #[test]
    fn test_table_names() {
        let sql = "CREATE TABLE users (id INTEGER); CREATE TABLE posts (id INTEGER);";
        let schema = Schema::from_sql(sql).unwrap();
        let names = schema.table_names();
        assert_eq!(names.len(), 2);
        assert!(names.contains(&"users".to_string()));
        assert!(names.contains(&"posts".to_string()));
    }
}