require 'fluent_plugins_spec_helper' require 'flydata/fluent-plugins/mysql/ddl_query_handler' require 'flydata/fluent-plugins/mysql/shared_query_handler_context' module Mysql describe DdlQueryHandler do include_context "query handler context" describe "#table_info" do context "alter table query with no db name" do let(:normalized_query) { "ALTER TABLE `apps` ADD `created_by_existing_admin` tinyint(1) DEFAULT 0;" } it do expect(subject.table_info(record)).to eq({db_name: "testdb", table_name: "apps"}) end end context "alter table query with db name" do let(:normalized_query) { "alter table testdb1.testtable1 add testcol varchar(256) DEFAULT ' /* ' COMMENT ' */ -- a part of COMMENT string' ;" } it do expect(subject.table_info(record)).to eq({db_name: "testdb1", table_name: "testtable1"}) end end context "alter table query with quoted db name" do let(:normalized_query) { <