Skip to content

Commit c3201e7

Browse files
use indoc, add setup
1 parent 4324377 commit c3201e7

20 files changed

+312
-18
lines changed

Cargo.lock

Lines changed: 7 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/pgls_completions/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ tokio = { version = "1.41.1", features = ["full"] }
3232

3333
[dev-dependencies]
3434
criterion.workspace = true
35-
indoc = "2.0.7"
35+
unindent = "0.2.4"
3636
insta.workspace = true
3737
pgls_test_utils.workspace = true
3838
regex = "1.12.2"

crates/pgls_completions/src/providers/columns.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ fn get_completion_text(ctx: &TreesitterContext, col: &Column) -> CompletionText
5050

5151
#[cfg(test)]
5252
mod tests {
53-
use indoc::indoc;
54-
5553
use sqlx::PgPool;
5654

5755
use crate::test_helper::{TestCompletionsCase, TestCompletionsSuite};
@@ -79,13 +77,13 @@ mod tests {
7977

8078
TestCompletionsSuite::new(&pool, Some(setup)).with_case(
8179
TestCompletionsCase::new()
82-
.inside_static_statement(indoc! {r#"
80+
.inside_static_statement(r#"
8381
select * from (
8482
<sql>
8583
) as subquery
8684
join public.users u
8785
on u.id = subquery.id;
88-
"#})
86+
"#)
8987
.type_sql("select id, narrator_id<1> from private.audio_books")
9088
.comment("Should prefer the one from private.audio_audiobooks, since the other tables are out of scope.")
9189
)

crates/pgls_completions/src/snapshots/pgls_completions__test_helper__completes_in_join_on_clause.snap

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,27 @@
22
source: crates/pgls_completions/src/test_helper.rs
33
expression: final_snapshot
44
---
5+
***Setup***
6+
7+
create schema auth;
8+
9+
create table auth.users (
10+
uid serial primary key,
11+
name text not null,
12+
email text unique not null
13+
);
14+
15+
create table auth.posts (
16+
pid serial primary key,
17+
user_id int not null references auth.users(uid),
18+
title text not null,
19+
content text,
20+
created_at timestamp default now()
21+
);
22+
23+
24+
--------------
25+
526
select u.id, auth.posts.content from auth.users u join auth.posts p on |
627
**Should prioritize primary keys here.**
728

crates/pgls_completions/src/snapshots/pgls_completions__test_helper__completes_quoted_columns.snap

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@
22
source: crates/pgls_completions/src/test_helper.rs
33
expression: final_snapshot
44
---
5+
***Setup***
6+
7+
create schema if not exists private;
8+
9+
create table private.users (
10+
id serial primary key,
11+
email text unique not null,
12+
name text not null,
13+
"quoted_column" text
14+
);
15+
16+
17+
--------------
18+
519
s|
620
select |
721

crates/pgls_completions/src/snapshots/pgls_completions__test_helper__completes_quoted_columns_with_aliases.snap

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,25 @@
22
source: crates/pgls_completions/src/test_helper.rs
33
expression: final_snapshot
44
---
5+
***Setup***
6+
7+
create schema if not exists private;
8+
9+
create table private.users (
10+
id serial primary key,
11+
email text unique not null,
12+
name text not null,
13+
"quoted_column" text
14+
);
15+
16+
create table public.names (
17+
uid serial references private.users(id),
18+
name text
19+
);
20+
21+
22+
--------------
23+
524
***Case 1:***
625

726
s|

crates/pgls_completions/src/snapshots/pgls_completions__test_helper__does_not_complete_cols_in_join_clauses.snap

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,27 @@
22
source: crates/pgls_completions/src/test_helper.rs
33
expression: final_snapshot
44
---
5+
***Setup***
6+
7+
create schema auth;
8+
9+
create table auth.users (
10+
uid serial primary key,
11+
name text not null,
12+
email text unique not null
13+
);
14+
15+
create table auth.posts (
16+
pid serial primary key,
17+
user_id int not null references auth.users(uid),
18+
title text not null,
19+
content text,
20+
created_at timestamp default now()
21+
);
22+
23+
24+
--------------
25+
526
s|
627
select |
728

crates/pgls_completions/src/snapshots/pgls_completions__test_helper__filters_out_by_aliases_in_join_on.snap

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,27 @@
22
source: crates/pgls_completions/src/test_helper.rs
33
expression: final_snapshot
44
---
5+
***Setup***
6+
7+
create schema auth;
8+
9+
create table auth.users (
10+
uid serial primary key,
11+
name text not null,
12+
email text unique not null
13+
);
14+
15+
create table auth.posts (
16+
pid serial primary key,
17+
user_id int not null references auth.users(uid),
18+
title text not null,
19+
content text,
20+
created_at timestamp default now()
21+
);
22+
23+
24+
--------------
25+
526
select u.id, p.content from auth.users u join auth.posts p |
627
select u.id, p.content from auth.users u join auth.posts p o|
728
select u.id, p.content from auth.users u join auth.posts p on |

crates/pgls_completions/src/snapshots/pgls_completions__test_helper__filters_out_by_aliases_in_select.snap

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,27 @@
22
source: crates/pgls_completions/src/test_helper.rs
33
expression: final_snapshot
44
---
5+
***Setup***
6+
7+
create schema auth;
8+
9+
create table auth.users (
10+
uid serial primary key,
11+
name text not null,
12+
email text unique not null
13+
);
14+
15+
create table auth.posts (
16+
pid serial primary key,
17+
user_id int not null references auth.users(uid),
18+
title text not null,
19+
content text,
20+
created_at timestamp default now()
21+
);
22+
23+
24+
--------------
25+
526
s| from auth.users u join auth.posts p on u.id = p.user_id;
627
select | from auth.users u join auth.posts p on u.id = p.user_id;
728

crates/pgls_completions/src/snapshots/pgls_completions__test_helper__handles_nested_queries.snap

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,28 @@
22
source: crates/pgls_completions/src/test_helper.rs
33
expression: final_snapshot
44
---
5+
***Setup***
6+
7+
create schema private;
8+
9+
create table public.users (
10+
id serial primary key,
11+
name text
12+
);
13+
14+
create table public.audio_books (
15+
id serial primary key,
16+
narrator text
17+
);
18+
19+
create table private.audio_books (
20+
id serial primary key,
21+
narrator_id text
22+
);
23+
24+
25+
--------------
26+
527
select * from (
628
|
729
) as subquery

0 commit comments

Comments
 (0)