Files
notion-sql/tests/cli.rs
T
james.maes fb10ae20c3 feat: Implement v1.0.0 release with comprehensive audit fixes
- Fix clippy warnings in test code by adding #[allow(dead_code)]
- Move all unit tests from source files to tests/ directory
- Add integration tests for SQL parsing and schema operations
- Create examples directory with 5 SQL query examples
- Add Windows CI job to ci.yml for cross-platform coverage
- Update Cargo.toml with documentation and readme fields
- Add comprehensive clean room audit documentation

All 39 tests passing, clippy clean, formatting verified
2026-06-02 13:12:50 -05:00

32 lines
1.1 KiB
Rust

//! Tests for CLI-level safety checks that do not require Notion HTTP access.
use notion_sql::{cli::guard_applied_full_table_mutation, schema::DatabaseSchema};
use serde_json::json;
#[test]
fn rejects_applied_full_table_mutation_without_force_all() {
let error = guard_applied_full_table_mutation("DELETE", true, false, false).unwrap_err();
assert!(error.to_string().contains("requires a WHERE clause"));
}
#[test]
fn allows_dry_run_or_forced_full_table_mutation() {
guard_applied_full_table_mutation("DELETE", false, false, false).unwrap();
guard_applied_full_table_mutation("DELETE", true, true, false).unwrap();
guard_applied_full_table_mutation("DELETE", true, false, true).unwrap();
}
#[test]
fn rejects_select_all_with_unsupported_columns() {
let schema = DatabaseSchema::from_notion_database(&json!({
"properties": {
"Name": { "type": "title", "title": {} },
"Formula": { "type": "formula", "formula": {} }
}
}))
.unwrap();
let error = schema.unsupported_columns().join(" ");
assert!(error.contains("Formula"));
}