Skip to content

Commit 62a7b99

Browse files
committed
Fix tests
Signed-off-by: Moritz Hoffmann <mh@materialize.com>
1 parent 5247666 commit 62a7b99

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

src/catalog/src/durable/transaction.rs

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2703,12 +2703,10 @@ trait UniqueName {
27032703
mod unique_name {
27042704
use crate::durable::objects::*;
27052705

2706-
use crate::durable::transaction::UniqueName;
2707-
27082706
macro_rules! impl_unique_name {
27092707
($($t:ty),* $(,)?) => {
27102708
$(
2711-
impl UniqueName for $t {
2709+
impl crate::durable::transaction::UniqueName for $t {
27122710
const HAS_UNIQUE_NAME: bool = true;
27132711
fn unique_name(&self) -> &str {
27142712
&self.name
@@ -2721,7 +2719,7 @@ mod unique_name {
27212719
macro_rules! impl_no_unique_name {
27222720
($($t:ty),* $(,)?) => {
27232721
$(
2724-
impl UniqueName for $t {
2722+
impl crate::durable::transaction::UniqueName for $t {
27252723
const HAS_UNIQUE_NAME: bool = false;
27262724
fn unique_name(&self) -> &str {
27272725
""
@@ -2756,6 +2754,11 @@ mod unique_name {
27562754
SystemPrivilegesValue,
27572755
TxnWalShardValue,
27582756
);
2757+
2758+
#[cfg(test)]
2759+
mod test {
2760+
impl_no_unique_name!(String,);
2761+
}
27592762
}
27602763

27612764
/// TableTransaction emulates some features of a typical SQL transaction over
@@ -2930,7 +2933,7 @@ where
29302933
// Deleted items don't exist so shouldn't be visited, but still suppress
29312934
// visiting the key later.
29322935
if let Some(v) = v {
2933-
f(k, &v);
2936+
f(k, v);
29342937
}
29352938
}
29362939
for (k, v) in self.initial.iter() {
@@ -3318,12 +3321,20 @@ mod tests {
33183321
)
33193322
.unwrap();
33203323

3321-
table
3324+
// Ideally, we compare for errors here, but it's hard/impossible to implement PartialEq
3325+
// for DurableCatalogError.
3326+
assert!(table
33223327
.insert(2i64.to_le_bytes().to_vec(), "b".to_string(), 0)
3323-
.unwrap();
3324-
table
3328+
.is_ok());
3329+
assert!(table
33253330
.insert(3i64.to_le_bytes().to_vec(), "c".to_string(), 0)
3326-
.unwrap();
3331+
.is_ok());
3332+
assert!(table
3333+
.insert(1i64.to_le_bytes().to_vec(), "c".to_string(), 0)
3334+
.is_err());
3335+
assert!(table
3336+
.insert(4i64.to_le_bytes().to_vec(), "c".to_string(), 0)
3337+
.is_err());
33273338
}
33283339

33293340
#[mz_ore::test]

0 commit comments

Comments
 (0)