Sha256: e9d6b5ef87b8ced7c1e73abceefef8c588c4f8591e66f94ddb7d1e58b54346ff

Contents?: true

Size: 1.51 KB

Versions: 1

Compression:

Stored size: 1.51 KB

Contents

require 'test/unit'

class TestSelect < Test::Unit::TestCase
    include Marjoree

    def setup
        $db.do( "CREATE TABLE TEST_TABLE( id    int     NOT NULL,    value int NOT NULL )" )
        $db.do( "INSERT INTO TEST_TABLE ( id, value ) VALUES( 0, 10 )" )
        $db.do( "INSERT INTO TEST_TABLE ( id, value ) VALUES( 1, 11 )" )
        $db.do( "CREATE VIEW VW_TEST_TABLE AS SELECT * FROM TEST_TABLE" )
        load_sproc 'test_sproc.sp'
    end

    def test_select
        result_set = select( "TEST_TABLE" )

        assert_equal( 2, result_set.count )
    end

    def test_select_with_bad_table
        begin
            resultSet = select( "TABLE_NOT_INT_DB" )
            fail
        rescue ODBC::Error
        end
    end

    def test_get_user_tables
        assert get_user_tables.include?( "TEST_TABLE" )
        assert !get_user_tables.include?( "MADE_UP_TABLE" )
    end

    def test_get_user_tables
        assert get_user_views.include?( "VW_TEST_TABLE" )
    end

    def test_get_user_sprocs
        assert get_user_sprocs.include?( "test_sproc" )
    end

    def teardown
        $db.do( "DROP PROCEDURE test_sproc" )
        $db.do( "DROP VIEW VW_TEST_TABLE" )
        $db.do( "TRUNCATE TABLE TEST_TABLE" )
        $db.do( "DROP TABLE TEST_TABLE" )
    end

    private

    def load_sproc( sproc_name )
        dir = File.dirname(__FILE__)
        sproc_contents = IO.readlines( "#{dir}/../sprocs/#{sproc_name}" ).join
        $db.do sproc_contents
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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