Skip to content

Commit

Permalink
Merge branch 'main' into query_sytem_local
Browse files Browse the repository at this point in the history
  • Loading branch information
rukai authored Aug 15, 2022
2 parents 9427869 + a57c01c commit 07081f4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
9 changes: 3 additions & 6 deletions shotover-proxy/tests/cassandra_int_tests/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,9 @@ async fn drop_function(session: &CassandraConnection) {
).await;
run_query(session, "DROP FUNCTION test_function_keyspace.my_function").await;

let statement = "SELECT test_function_keyspace.my_function(x) FROM test_function_keyspace.test_function_table WHERE id=1;";
let result = session.execute_expect_err(statement).to_string();

assert_eq!(
result,
"Cassandra detailed error SERVER_INVALID_QUERY: Unknown function 'test_function_keyspace.my_function'"
session.execute_expect_err_contains(
"SELECT test_function_keyspace.my_function(x) FROM test_function_keyspace.test_function_table WHERE id=1;",
"Unknown function 'test_function_keyspace.my_function'",
);
}

Expand Down
7 changes: 4 additions & 3 deletions shotover-proxy/tests/cassandra_int_tests/udt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ async fn test_drop_udt(session: &CassandraConnection) {
)
.await;
run_query(session, "DROP TYPE test_udt_keyspace.test_type_drop_me;").await;
let statement = "CREATE TABLE test_udt_keyspace.test_delete_table (id int PRIMARY KEY, foo test_type_drop_me);";
let result = session.execute_expect_err(statement).to_string();
assert_eq!(result, "Cassandra detailed error SERVER_INVALID_QUERY: Unknown type test_udt_keyspace.test_type_drop_me");
session.execute_expect_err_contains(
"CREATE TABLE test_udt_keyspace.test_delete_table (id int PRIMARY KEY, foo test_type_drop_me);",
"Unknown type test_udt_keyspace.test_type_drop_me",
);
}

pub async fn test(session: &CassandraConnection) {
Expand Down
9 changes: 9 additions & 0 deletions shotover-proxy/tests/helpers/cassandra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,15 @@ impl CassandraConnection {
}
}

#[allow(unused)]
pub fn execute_expect_err_contains(&self, query: &str, contains: &str) {
let result = self.execute_expect_err(query).to_string();
assert!(
result.contains(contains),
"Expected the error to contain '{contains}' but it did not and was instead '{result}'"
);
}

#[allow(unused)]
pub fn prepare(&self, query: &str) -> PreparedStatement {
match self {
Expand Down

0 comments on commit 07081f4

Please sign in to comment.