Sha256: c8797131bcf044bb36d3ffc1889e489b1df6a933d559cdc460c2fb361b4fe16f

Contents?: true

Size: 1.27 KB

Versions: 1

Compression:

Stored size: 1.27 KB

Contents

require 'test/unit'
require 'marjoree/odbc_connection_wrapper'

class TestSingleOdbcConnectionWrapper < Test::Unit::TestCase

    def setup
        @original_odbc_config_path = OdbcConnectionWrapper.odbc_config_path
        OdbcConnectionWrapper.odbc_config_path = './tests/single_odbc_config/connections.yml'

        @testee = OdbcConnectionWrapper.new
    end

    def test_single_db_connection
        @testee.connect_me_to( "first_db" )
        @testee.execute( "CREATE TABLE WRAPPER_TEST_TABLE( id INT )")
        assert( table_in_db?( "WRAPPER_TEST_TABLE" ) )

        @testee.connect_me_to( "default" )
        assert( table_in_db?( "WRAPPER_TEST_TABLE" ) )
    end

    def teardown
        @testee.connect_me_to( "first_db" )
        @testee.execute( "DROP TABLE WRAPPER_TEST_TABLE" ) if ( table_in_db?( "WRAPPER_TEST_TABLE" ) )
        @testee.disconnect_me
        OdbcConnectionWrapper.odbc_config_path = @original_odbc_config_path
    end

    private

    def table_in_db?( table_name )
        result_set =  @testee.execute( "SELECT * FROM sysobjects WHERE type = 'U'" )
        object_names = []
        result_set.hashes.each do |row|
            object_names << row[:name]
        end
        return object_names.include?( table_name )
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
marjoree-0.0.9 ./tests/marjoree/test_single_odbc_connection_wrapper.rb