MCPcopy Create free account
hub / github.com/erans/pgsqlite / test_invalid_enum_value_error

Function test_invalid_enum_value_error

tests/enum_error_handling_test.rs:5–30  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3
4#[tokio::test]
5async fn test_invalid_enum_value_error() {
6 let server = setup_test_server().await;
7 let client = &server.client;
8
9 // Create an ENUM type using simple_query for DDL
10 client.simple_query("CREATE TYPE mood AS ENUM ('happy', 'sad', 'neutral')")
11 .await
12 .unwrap();
13
14 // Create a table with ENUM column using simple_query for DDL
15 client.simple_query("CREATE TABLE person (name TEXT, current_mood mood)")
16 .await
17 .unwrap();
18
19 // Try to insert an invalid enum value
20 let result = client.execute(
21 "INSERT INTO person (name, current_mood) VALUES ('Alice', 'angry')",
22 &[]
23 ).await;
24
25 assert!(result.is_err());
26 let error = result.unwrap_err();
27 let error_str = error.to_string();
28 assert!(error_str.contains("invalid input value for enum mood: \"angry\""),
29 "Expected PostgreSQL-compatible error message, got: {error_str}");
30}
31
32#[tokio::test]
33async fn test_type_does_not_exist_error() {

Callers

nothing calls this directly

Calls 2

setup_test_serverFunction · 0.85
executeMethod · 0.45

Tested by

no test coverage detected