From 7d2604f319f9af4256cdab7a4c1f49dc93bcb730 Mon Sep 17 00:00:00 2001 From: Chris Tsang Date: Sat, 27 Jan 2024 14:42:51 +0000 Subject: [PATCH] Add test case --- tests/postgres/types.rs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/postgres/types.rs b/tests/postgres/types.rs index eb6d70b9c..4a69dff44 100644 --- a/tests/postgres/types.rs +++ b/tests/postgres/types.rs @@ -24,6 +24,38 @@ fn create_2() { ); } +#[test] +fn create_3() { + assert_eq!( + Type::create() + .as_enum(Tea::Enum) + .values([Tea::EverydayTea, Tea::BreakfastTea]) + .to_string(PostgresQueryBuilder), + r#"CREATE TYPE "tea" AS ENUM ('EverydayTea', 'BreakfastTea')"# + ); + + enum Tea { + Enum, + EverydayTea, + BreakfastTea, + } + + impl sea_query::Iden for Tea { + fn unquoted(&self, s: &mut dyn std::fmt::Write) { + write!( + s, + "{}", + match self { + Self::Enum => "tea", + Self::EverydayTea => "EverydayTea", + Self::BreakfastTea => "BreakfastTea", + } + ) + .unwrap(); + } + } +} + #[test] fn drop_1() { assert_eq!(