From 13af2b004a58889af42ab91a2f8db2a217bf3e66 Mon Sep 17 00:00:00 2001 From: Jacek Malec Date: Thu, 2 Jan 2025 12:01:47 +0000 Subject: [PATCH] test: cover invalid enum runtime error --- .../tests/queries/data_types/enum_type.rs | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/query-engine/connector-test-kit-rs/query-engine-tests/tests/queries/data_types/enum_type.rs b/query-engine/connector-test-kit-rs/query-engine-tests/tests/queries/data_types/enum_type.rs index f13cb15b9746..9e146d5ade1a 100644 --- a/query-engine/connector-test-kit-rs/query-engine-tests/tests/queries/data_types/enum_type.rs +++ b/query-engine/connector-test-kit-rs/query-engine-tests/tests/queries/data_types/enum_type.rs @@ -101,6 +101,45 @@ mod enum_type { Ok(()) } + #[connector_test(only(Sqlite))] + async fn read_one_invalid_sqlite(runner: Runner) -> TestResult<()> { + runner + .query(r#"mutation { executeRaw(query: "INSERT INTO \"TestModel\" (id, my_enum) VALUES(1, 'D')", parameters: "[]") }"#) + .await? + .assert_success(); + + match runner.protocol() { + EngineProtocol::Graphql => { + let res = runner + .query(r#"{ findUniqueTestModel(where: { id: 1 }) { my_enum } }"#) + .await?; + res.assert_failure(None, Some("Value 'D' not found in enum 'MyEnum'".to_owned())); + } + EngineProtocol::Json => { + let res = runner + .query_json( + r#"{ + "modelName": "TestModel", + "action": "findUnique", + "query": { + "arguments": { + "where": { "id": 1 } + }, + "selection": { + "my_enum": true + } + } + }"#, + ) + .await?; + + res.assert_failure(None, Some("Value 'D' not found in enum 'MyEnum'".to_owned())); + } + } + + Ok(()) + } + async fn create_test_data(runner: &Runner) -> TestResult<()> { create_row(runner, r#"{ id: 1, my_enum: A }"#).await?; create_row(runner, r#"{ id: 2, my_enum: B }"#).await?;