Skip to content

Commit

Permalink
test: add test cases for joins
Browse files Browse the repository at this point in the history
Adds test cases for simple foreign keys, many to many tables, and joins
between tables. This tests the functionality of the commutator and
hash functions for the `ulid` type in postgres.

ref: [#13][issue]

[issue]: #13
  • Loading branch information
jmcdo29 authored and pksunkara committed Aug 12, 2023
1 parent 5485957 commit 03e4f00
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,48 @@ mod tests {
let result = Spi::get_one::<ulid>("SELECT gen_ulid();").unwrap();
assert!(result.is_some());
}

#[pg_test]
fn test_hash() {
Spi::run(
"CREATE TABLE foo (
id ulid,
data TEXT
);
CREATE TABLE bar (
id ulid,
foo_id ulid
);
INSERT INTO foo DEFAULT VALUES;
INSERT INTO bar DEFAULT VALUES;
SELECT *
FROM bar
JOIN foo ON bar.id = foo.id;",
)
.unwrap();
}

#[pg_test]
fn test_commutator() {
Spi::run(
"CREATE TABLE foo (
id ulid,
data TEXT
);
CREATE TABLE bar (
id ulid
);
SELECT *
FROM bar
JOIN foo ON bar.id = foo.id;",
)
.unwrap();
}
}

/// This module is required by `cargo pgrx test` invocations.
Expand Down

0 comments on commit 03e4f00

Please sign in to comment.