Skip to content

Commit 4f51cbe

Browse files
committed
feat: Add tests for all crud things currently supported
1 parent ea565ce commit 4f51cbe

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

src/lib.rs

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,8 +383,41 @@ mod tests {
383383

384384
assert_eq!((Some(format!("foo")), Some(format!("bar"))), query_result);
385385
let query_result = Spi::get_two::<String, String>("SELECT * FROM test WHERE key='bar'")
386-
.expect("Select should work");
386+
.expect("SELECT should work");
387387

388388
assert_eq!((Some(format!("bar")), Some(format!("baz"))), query_result);
389389
}
390+
391+
#[pg_test]
392+
fn test_update() {
393+
let (_container, url) = create_container();
394+
395+
create_fdt(url);
396+
397+
Spi::run("INSERT INTO test (key, value) VALUES ('foo','bar'),('bar','baz')")
398+
.expect("INSERT should work");
399+
400+
Spi::run("UPDATE test SET value='test_successful'").expect("UPDATE should work");
401+
402+
let query_result =
403+
Spi::get_one::<String>("SELECT value FROM test;").expect("SELECT should work");
404+
405+
assert_eq!(Some(format!("test_successful")), query_result);
406+
}
407+
408+
#[pg_test]
409+
fn test_delete() {
410+
let (_container, url) = create_container();
411+
412+
create_fdt(url);
413+
414+
Spi::run("INSERT INTO test (key, value) VALUES ('foo','bar'),('bar','baz')")
415+
.expect("INSERT should work");
416+
417+
Spi::run("DELETE FROM test").expect("DELETE should work");
418+
419+
let query_result = Spi::get_one::<String>("SELECT value FROM test;");
420+
421+
assert_eq!(Err(spi::SpiError::InvalidPosition), query_result);
422+
}
390423
}

0 commit comments

Comments
 (0)