From 803481792bd1b78daefe72795cb37ca2bd3367aa Mon Sep 17 00:00:00 2001 From: Avi Kivity Date: Sun, 26 Apr 2015 18:44:56 +0300 Subject: [PATCH] tests: test cql3 type-cast with user-defined types --- tests/urchin/cql_query_test.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/urchin/cql_query_test.cc b/tests/urchin/cql_query_test.cc index 65c111f02e..3859ded8ad 100644 --- a/tests/urchin/cql_query_test.cc +++ b/tests/urchin/cql_query_test.cc @@ -779,6 +779,8 @@ SEASTAR_TEST_CASE(test_user_type) { {int32_type, long_type, utf8_type}); }; return do_with_cql_env([make_user_type] (cql_test_env& e) { + // We don't have "CREATE TYPE" yet, so we must insert the type manually + e.local_db().find_or_create_keyspace("ks")._user_types.add_type(make_user_type()); return e.create_table([make_user_type] (auto ks_name) { // CQL: "create table cf (id int primary key, t ut1)"; return schema({}, ks_name, "cf", @@ -801,6 +803,19 @@ SEASTAR_TEST_CASE(test_user_type) { .with_rows({ {int32_type->decompose(int32_t(1002)), long_type->decompose(int64_t(2002)), utf8_type->decompose(sstring("abc2"))}, }); + }).then([&e] { + return e.execute_cql("insert into cf (id, t) values (2, (frozen)(2001, 3001, 'abc4'));").discard_result(); + }).then([&e] { + return e.execute_cql("select t from cf where id = 2;"); + }).then([&e, make_user_type] (shared_ptr msg) { + auto ut = make_user_type(); + auto ut_val = user_type_impl::native_type({boost::any(int32_t(2001)), + boost::any(int64_t(3001)), + boost::any(sstring("abc4"))}); + assert_that(msg).is_rows() + .with_rows({ + {ut->decompose(ut_val)}, + }); }); }); }