Skip to content

Commit 31026d4

Browse files
adjustments
1 parent 6330d02 commit 31026d4

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

crates/pglt_test_macros/README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,25 @@ You can generate tests like so:
3939
}
4040
```
4141

42-
Test name is the "snake case" version of the file name.
43-
this will generate the following for each file:
42+
Given a `crate/tests/queries/some_test_abc.sql` file and a `run_test` function, this will generate the following:
4443

4544
```rust
4645
#[test]
47-
pub fn somefilename()
46+
pub fn some_test_abc()
4847
{
49-
let test_file = "<crate's cargo.toml full path>/tests/sometest.txt";
50-
let test_expected_file = "<crate's cargo.toml full path>/tests/sometest.expected.txt";
51-
run_test(test_file, test_expected_file);
48+
let test_file = "<crate>/tests/queries/some_test_abc.sql";
49+
let test_expected_file = "<crate>/tests/queries/some_test_abc.expected.sql";
50+
let parent = "<crate>/tests/queries";
51+
run_test(test_file, test_expected_file, parent);
5252
}
5353
```
5454

55+
This will be replicated for each file matched by the glob pattern.
56+
5557
## Pitfalls
5658

5759
- If you use a Rust-keyword as a file name, this'll result in invalid syntax for the generated tests.
60+
- You might get linting errors if your test files aren't snake case.
5861
- All files of the glob-pattern must (currently) be `.sql` files.
5962
- The `.expected.sql` file-name will always be passed, even if the file doesn't exist.
6063
- The macro will wrap your tests in a `mod tests { .. }` module. If you need multiple generations, wrap them in modules like so: ```mod some_test { tests_macros::gen_tests! { .. } }`.

0 commit comments

Comments
 (0)