diff --git a/test/duckdb_test/column_test.rb b/test/duckdb_test/column_test.rb index 1a2a68e..7aa71dc 100644 --- a/test/duckdb_test/column_test.rb +++ b/test/duckdb_test/column_test.rb @@ -5,9 +5,14 @@ module DuckDBTest class ColumnTest < Minitest::Test def setup - @@con ||= create_data - @result = @@con.query('SELECT * from table1') - @columns = @result.columns + @db = DuckDB::Database.open + @con = @db.connect + create_data + end + + def teardown + @con.close if @con + @db = nil end def test_type @@ -36,6 +41,9 @@ def test_type expected.push(:list) expected.push(:list) expected.push(:struct) + expected.push(:uuid) + expected.push(:varchar) # json + expected.push(:map) assert_equal( expected, @columns.map(&:type) @@ -68,6 +76,9 @@ def test_name expected.push('int_list_col') expected.push('varchar_list_col') expected.push('struct_col') + expected.push('uuid_col') + expected.push('json_col') + expected.push('map_col') assert_equal( expected, @columns.map(&:name) @@ -77,12 +88,11 @@ def test_name private def create_data - @@db ||= DuckDB::Database.open # FIXME - con = @@db.connect - con.query(create_type_enum_sql) - con.query(create_table_sql) - con.query(insert_sql) - con + @con.query(create_type_enum_sql) + @con.query(create_table_sql) + @con.query(insert_sql) + @result = @con.query('SELECT * FROM table1') + @columns = @result.columns end def create_type_enum_sql @@ -117,6 +127,9 @@ def create_table_sql sql += ', int_list_col INT[]' sql += ', varchar_list_col VARCHAR[]' sql += ', struct_col STRUCT(word VARCHAR, length INTEGER)' + sql += ', uuid_col UUID' + sql += ', json_col JSON' + sql += ', map_col MAP(INTEGER, VARCHAR)' sql += ')' sql end @@ -150,6 +163,9 @@ def insert_sql sql += ', [1, 2, 3]' sql += ", ['a', 'b', 'c']" sql += ", ROW('Ruby', 4)" + sql += ", '#{SecureRandom.uuid}'" + sql += ", '{\"key\": \"value\"}'" + sql += ", MAP([1, 2], ['Dog', 'Cat'])" sql += ')' sql end