Skip to content

Commit

Permalink
test: update assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
jacek-prisma committed Dec 18, 2024
1 parent 0fa41c2 commit 131a7fb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion psl/psl/tests/attributes/id_positive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ fn should_allow_string_ids_with_ulid() {
.assert_has_scalar_field("id")
.assert_scalar_type(ScalarType::String)
.assert_default_value()
.assert_cuid();
.assert_ulid();

model.assert_id_on_fields(&["id"]);
}
Expand Down
14 changes: 14 additions & 0 deletions psl/psl/tests/common/asserts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ pub(crate) trait DefaultValueAssert {
fn assert_constant(&self, val: &str) -> &Self;
fn assert_bytes(&self, val: &[u8]) -> &Self;
fn assert_now(&self) -> &Self;
fn assert_ulid(&self) -> &Self;
fn assert_cuid(&self) -> &Self;
fn assert_cuid_version(&self, version: u8) -> &Self;
fn assert_uuid(&self) -> &Self;
Expand Down Expand Up @@ -429,6 +430,12 @@ impl DefaultValueAssert for walkers::DefaultValueWalker<'_> {
self
}

#[track_caller]
fn assert_ulid(&self) -> &Self {
self.value().assert_ulid();
self
}

#[track_caller]
fn assert_cuid(&self) -> &Self {
self.value().assert_cuid();
Expand Down Expand Up @@ -634,6 +641,13 @@ impl DefaultValueAssert for ast::Expression {
self
}

#[track_caller]
fn assert_ulid(&self) -> &Self {
assert!(matches!(self, ast::Expression::Function(name, _, _) if name == "ulid"));

self
}

#[track_caller]
fn assert_cuid(&self) -> &Self {
assert!(matches!(self, ast::Expression::Function(name, _, _) if name == "cuid"));
Expand Down

0 comments on commit 131a7fb

Please sign in to comment.