Commit 2213445
Changed files (2)
tests
fixtures
tests/fixtures/README.md
@@ -1,43 +0,0 @@
-# Test Fixtures
-
-This directory contains test fixtures for `xlg-sqlfmt`. Each fixture is a scenario that tests specific SQL formatting behavior.
-
-## Structure
-
-Each fixture is a directory containing:
-- `input.sql` - The SQL to be formatted (piped to stdin)
-- `output.sql` - The expected formatted output (compared with stdout)
-
-## Adding New Test Cases
-
-To add a new test case:
-
-1. Create a new directory with a descriptive name: `tests/fixtures/my_new_test/`
-2. Add `input.sql` with your test SQL
-3. Add `output.sql` with the expected formatted result
-4. Run tests - the new fixture will be automatically discovered!
-
-## Running Tests
-
-```bash
-# Run all fixture tests
-cargo test --test fixture_tests
-
-# Run a specific fixture test
-cargo test test_fixture_basic_select --test fixture_tests
-
-# See all discovered fixtures
-cargo test test_fixture_discovery --test fixture_tests -- --nocapture
-
-# Test all fixtures at once
-cargo test test_all_fixtures --test fixture_tests
-```
-
-## Special Cases
-
-- **invalid_sql**: For fixtures that should fail parsing, they will be tested with `.failure()` instead of `.success()`
-- The test automatically detects invalid SQL fixtures by the directory name "invalid_sql"
-
-## Current Fixtures
-
-Run `cargo test test_fixture_discovery --test fixture_tests -- --nocapture` to see all current fixtures.
\ No newline at end of file
tests/fixture_tests.rs
@@ -69,81 +69,3 @@ fn test_all_fixtures() {
run_fixture_test(&fixture_path);
}
}
-
-#[test]
-fn test_fixtures_individually() {
- let fixtures = discover_fixtures();
-
- for fixture_path in fixtures {
- let scenario_name = fixture_path.file_name().unwrap().to_str().unwrap();
-
- // Create individual test cases that can be run separately
- match scenario_name {
- "basic_select" => run_fixture_test(&fixture_path),
- "simple_projection" => run_fixture_test(&fixture_path),
- "multiple_and_conditions" => run_fixture_test(&fixture_path),
- "join_query" => run_fixture_test(&fixture_path),
- "subquery" => run_fixture_test(&fixture_path),
- "cte" => run_fixture_test(&fixture_path),
- "case_expression" => run_fixture_test(&fixture_path),
- "union_query" => run_fixture_test(&fixture_path),
- "invalid_sql" => run_fixture_test(&fixture_path),
- _ => {
- // This ensures new fixtures are automatically tested
- println!("Testing new fixture: {}", scenario_name);
- run_fixture_test(&fixture_path);
- }
- }
- }
-}
-
-// This test can be used to check which fixtures are available
-#[test]
-fn test_fixture_discovery() {
- let fixtures = discover_fixtures();
-
- println!("Discovered fixtures:");
- for fixture in &fixtures {
- let name = fixture.file_name().unwrap().to_str().unwrap();
- println!(" - {}", name);
- }
-
- // This test always passes but shows what fixtures were found
- assert!(
- !fixtures.is_empty(),
- "Should have found at least some fixtures"
- );
-}
-
-#[cfg(test)]
-mod fixture_specific_tests {
- use super::*;
-
- // These are generated test functions that run individual fixtures
- // You can run specific fixtures with: cargo test test_fixture_basic_select
-
- macro_rules! generate_fixture_test {
- ($test_name:ident, $fixture_name:literal) => {
- #[test]
- fn $test_name() {
- let fixture_path = Path::new("tests/fixtures").join($fixture_name);
- if fixture_path.exists() {
- run_fixture_test(&fixture_path);
- }
- }
- };
- }
-
- generate_fixture_test!(test_fixture_basic_select, "basic_select");
- generate_fixture_test!(test_fixture_simple_projection, "simple_projection");
- generate_fixture_test!(
- test_fixture_multiple_and_conditions,
- "multiple_and_conditions"
- );
- generate_fixture_test!(test_fixture_join_query, "join_query");
- generate_fixture_test!(test_fixture_subquery, "subquery");
- generate_fixture_test!(test_fixture_cte, "cte");
- generate_fixture_test!(test_fixture_case_expression, "case_expression");
- generate_fixture_test!(test_fixture_union_query, "union_query");
- generate_fixture_test!(test_fixture_invalid_sql, "invalid_sql");
-}