Skip to content

Commit a825e6c

Browse files
committed
progress
1 parent 1996951 commit a825e6c

12 files changed

+99
-259
lines changed

crates/pgt_cli/tests/commands/check.rs renamed to crates/pgt_cli/tests/assert_check.rs

Lines changed: 84 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,88 @@ use std::process::ExitStatus;
66
const BIN: &str = "postgres-language-server";
77
const CONFIG_PATH: &str = "tests/fixtures/postgres-language-server.jsonc";
88

9+
#[test]
10+
#[cfg_attr(
11+
target_os = "windows",
12+
ignore = "snapshot expectations only validated on unix-like platforms"
13+
)]
14+
fn check_default_reporter_snapshot() {
15+
assert_snapshot!(run_check(&["tests/fixtures/test.sql"]));
16+
}
17+
18+
#[test]
19+
#[cfg_attr(
20+
target_os = "windows",
21+
ignore = "snapshot expectations only validated on unix-like platforms"
22+
)]
23+
fn check_github_reporter_snapshot() {
24+
assert_snapshot!(run_check(&[
25+
"--reporter",
26+
"github",
27+
"tests/fixtures/test.sql"
28+
]));
29+
}
30+
31+
#[test]
32+
#[cfg_attr(
33+
target_os = "windows",
34+
ignore = "snapshot expectations only validated on unix-like platforms"
35+
)]
36+
fn check_gitlab_reporter_snapshot() {
37+
assert_snapshot!(run_check(&[
38+
"--reporter",
39+
"gitlab",
40+
"tests/fixtures/test.sql"
41+
]));
42+
}
43+
44+
#[test]
45+
#[cfg_attr(
46+
target_os = "windows",
47+
ignore = "snapshot expectations only validated on unix-like platforms"
48+
)]
49+
fn check_junit_reporter_snapshot() {
50+
assert_snapshot!(run_check(&[
51+
"--reporter",
52+
"junit",
53+
"tests/fixtures/test.sql"
54+
]));
55+
}
56+
57+
#[test]
58+
#[cfg_attr(
59+
target_os = "windows",
60+
ignore = "snapshot expectations only validated on unix-like platforms"
61+
)]
62+
fn check_stdin_snapshot() {
63+
assert_snapshot!(run_check_with(
64+
&[
65+
"--config-path",
66+
CONFIG_PATH,
67+
"--stdin-file-path",
68+
"virtual.sql"
69+
],
70+
Some("alter tqjable stdin drop column id;\n"),
71+
None
72+
));
73+
}
74+
75+
#[test]
76+
#[cfg_attr(
77+
target_os = "windows",
78+
ignore = "snapshot expectations only validated on unix-like platforms"
79+
)]
80+
fn check_directory_traversal_snapshot() {
81+
let project_dir = Path::new("tests/fixtures/traversal");
82+
assert_snapshot!(run_check_with(
83+
&["--diagnostic-level", "info", "."],
84+
None,
85+
Some(project_dir)
86+
));
87+
}
88+
989
fn run_check(args: &[&str]) -> String {
10-
let mut full_args = vec!["check", "--config-path", CONFIG_PATH];
90+
let mut full_args = vec!["--config-path", CONFIG_PATH];
1191
full_args.extend_from_slice(args);
1292
run_check_with(&full_args, None, None)
1393
}
@@ -21,7 +101,9 @@ fn run_check_with(args: &[&str], stdin: Option<&str>, cwd: Option<&Path>) -> Str
21101
cmd.write_stdin(input);
22102
}
23103

24-
let output = cmd.args(args).output().expect("failed to run CLI");
104+
let mut full_args = vec!["check"];
105+
full_args.extend_from_slice(args);
106+
let output = cmd.args(full_args).output().expect("failed to run CLI");
25107

26108
normalize_output(
27109
output.status,
@@ -135,84 +217,3 @@ fn trim_trailing_newlines(mut value: String) -> String {
135217
}
136218
value
137219
}
138-
139-
#[test]
140-
#[cfg_attr(
141-
target_os = "windows",
142-
ignore = "snapshot expectations only validated on unix-like platforms"
143-
)]
144-
fn check_default_reporter_snapshot() {
145-
assert_snapshot!(run_check(&["tests/fixtures/test.sql"]));
146-
}
147-
148-
#[test]
149-
#[cfg_attr(
150-
target_os = "windows",
151-
ignore = "snapshot expectations only validated on unix-like platforms"
152-
)]
153-
fn check_github_reporter_snapshot() {
154-
assert_snapshot!(run_check(&[
155-
"--reporter",
156-
"github",
157-
"tests/fixtures/test.sql"
158-
]));
159-
}
160-
161-
#[test]
162-
#[cfg_attr(
163-
target_os = "windows",
164-
ignore = "snapshot expectations only validated on unix-like platforms"
165-
)]
166-
fn check_gitlab_reporter_snapshot() {
167-
assert_snapshot!(run_check(&[
168-
"--reporter",
169-
"gitlab",
170-
"tests/fixtures/test.sql"
171-
]));
172-
}
173-
174-
#[test]
175-
#[cfg_attr(
176-
target_os = "windows",
177-
ignore = "snapshot expectations only validated on unix-like platforms"
178-
)]
179-
fn check_junit_reporter_snapshot() {
180-
assert_snapshot!(run_check(&[
181-
"--reporter",
182-
"junit",
183-
"tests/fixtures/test.sql"
184-
]));
185-
}
186-
187-
#[test]
188-
#[cfg_attr(
189-
target_os = "windows",
190-
ignore = "snapshot expectations only validated on unix-like platforms"
191-
)]
192-
fn check_stdin_snapshot() {
193-
assert_snapshot!(run_check_with(
194-
&[
195-
"check",
196-
"--config-path",
197-
CONFIG_PATH,
198-
"--stdin-file-path",
199-
"virtual.sql"
200-
],
201-
Some("alter tqjable stdin drop column id;\n"),
202-
None
203-
));
204-
}
205-
206-
#[test]
207-
#[cfg_attr(
208-
target_os = "windows",
209-
ignore = "snapshot expectations only validated on unix-like platforms"
210-
)]
211-
fn check_directory_traversal_snapshot() {
212-
let project_dir = Path::new("tests/fixtures/traversal");
213-
assert_snapshot!(run_check_with(
214-
&["check", "--diagnostic-level", "info", "."],
215-
None,
216-
Some(project_dir)
217-
));
218-
}

crates/pgt_cli/tests/assert_cmd.rs

Lines changed: 0 additions & 137 deletions
This file was deleted.

crates/pgt_cli/tests/commands/mod.rs

Lines changed: 0 additions & 1 deletion
This file was deleted.

crates/pgt_cli/tests/commands/snapshots/main__commands__check__check_stdin_snapshot.snap

Lines changed: 0 additions & 9 deletions
This file was deleted.

crates/pgt_cli/tests/main.rs

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
source: crates/pgt_cli/tests/commands/check.rs
2+
source: crates/pgt_cli/tests/assert_check.rs
33
expression: "run_check(&[\"tests/fixtures/test.sql\"])"
44
snapshot_kind: text
55
---
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
source: crates/pgt_cli/tests/commands/check.rs
3-
expression: "run_check_with(&[\"check\", \"--diagnostic-level\", \"info\", \".\"], None,\nSome(project_dir))"
2+
source: crates/pgt_cli/tests/assert_check.rs
3+
expression: "run_check_with(&[\"--diagnostic-level\", \"info\", \".\"], None, Some(project_dir))"
44
snapshot_kind: text
55
---
66
status: failure
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
source: crates/pgt_cli/tests/commands/check.rs
2+
source: crates/pgt_cli/tests/assert_check.rs
33
expression: "run_check(&[\"--reporter\", \"github\", \"tests/fixtures/test.sql\"])"
44
snapshot_kind: text
55
---
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
source: crates/pgt_cli/tests/commands/check.rs
2+
source: crates/pgt_cli/tests/assert_check.rs
33
expression: "run_check(&[\"--reporter\", \"gitlab\", \"tests/fixtures/test.sql\"])"
44
snapshot_kind: text
55
---
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
source: crates/pgt_cli/tests/commands/check.rs
2+
source: crates/pgt_cli/tests/assert_check.rs
33
expression: "run_check(&[\"--reporter\", \"junit\", \"tests/fixtures/test.sql\"])"
44
snapshot_kind: text
55
---

0 commit comments

Comments
 (0)