// Copyright (c) 2026 Kirky.X
//
// Licensed under the MIT License
// See LICENSE file in the project root for full license information.

//! SqlReverser 单元测试

#[cfg(test)]
mod tests {
    use dbnexus::migration::sql_reverser::SqlReverser;

    #[test]
    fn test_reverse_create_table() {
        let up_sql = "CREATE TABLE users (id INT PRIMARY KEY, name VARCHAR(255));";
        let reverser = SqlReverser::new();
        let down_sql = reverser.reverse(up_sql).unwrap();
        assert!(down_sql.contains("DROP TABLE"));
        assert!(down_sql.contains("users"));
    }

    #[test]
    fn test_reverse_add_column() {
        let up_sql = "ALTER TABLE users ADD COLUMN email VARCHAR(255);";
        let reverser = SqlReverser::new();
        let down_sql = reverser.reverse(up_sql).unwrap();
        assert!(down_sql.contains("DROP COLUMN"));
        assert!(down_sql.contains("email"));
    }
}
