From 268521a695a0da57f8022bd792c5d8a02b7039cb Mon Sep 17 00:00:00 2001 From: psteinroe Date: Sun, 31 Aug 2025 17:01:06 +0200 Subject: [PATCH] chore: add test for multiline comments --- .../src/workspace/server.tests.rs | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/crates/pgt_workspace/src/workspace/server.tests.rs b/crates/pgt_workspace/src/workspace/server.tests.rs index 894d10426..074be97a3 100644 --- a/crates/pgt_workspace/src/workspace/server.tests.rs +++ b/crates/pgt_workspace/src/workspace/server.tests.rs @@ -331,3 +331,57 @@ async fn test_positional_params(test_db: PgPool) { assert_eq!(diagnostics.len(), 0, "Expected no diagnostic"); } + +#[sqlx::test(migrator = "pgt_test_utils::MIGRATIONS")] +async fn test_cstyle_comments(test_db: PgPool) { + let mut conf = PartialConfiguration::init(); + conf.merge_with(PartialConfiguration { + db: Some(PartialDatabaseConfiguration { + database: Some( + test_db + .connect_options() + .get_database() + .unwrap() + .to_string(), + ), + ..Default::default() + }), + ..Default::default() + }); + + let workspace = get_test_workspace(Some(conf)).expect("Unable to create test workspace"); + + let path = PgTPath::new("test.sql"); + + let content = r#" + /* + * a + * multi-line + * comment. + */ + select 1; /* Another comment */ + -- A single line comment + select 2; -- Another single line comment + "#; + + workspace + .open_file(OpenFileParams { + path: path.clone(), + content: content.into(), + version: 1, + }) + .expect("Unable to open test file"); + + let diagnostics = workspace + .pull_diagnostics(crate::workspace::PullDiagnosticsParams { + path: path.clone(), + categories: RuleCategories::all(), + max_diagnostics: 100, + only: vec![], + skip: vec![], + }) + .expect("Unable to pull diagnostics") + .diagnostics; + + assert_eq!(diagnostics.len(), 0, "Expected no diagnostic"); +}