Sha256: a0b880d9a6a5f099a1ea782032b8b35e75f542c4639d15b7e3bdcfa262d2143f

Contents?: true

Size: 1.76 KB

Versions: 1

Compression:

Stored size: 1.76 KB

Contents

require 'test/unit'

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

    def setup
        $db.do( "CREATE TABLE TEST_TABLE( id    int     NOT NULL,    value varchar(20) NOT NULL )" )
        $db.do( "INSERT INTO TEST_TABLE ( id, value ) VALUES( 0, 'stuff' )" )
        $db.do( "INSERT INTO TEST_TABLE ( id, value ) VALUES( 1, 'more stuff' )" )
    end

    def test_update
        assert( contains?( "TEST_TABLE", :id => 0, :value => 'stuff' ) )

        update( "TEST_TABLE", { :id => 0 }, :value => 'more stuff' )
        assert( !contains?( "TEST_TABLE", :id => 0, :value => 'stuff' ) )
        assert( contains?( "TEST_TABLE", :id => 0, :value => 'more stuff' ) )
    end

    def test_update_with_no_where_clause
        assert( contains?( "TEST_TABLE", :id => 0, :value => 'stuff' ) )

        update( "TEST_TABLE", {}, :value => 'more stuff' )
        assert( !contains?( "TEST_TABLE", :id => 0, :value => 'stuff' ) )
        assert( contains?( "TEST_TABLE", :id => 0, :value => 'more stuff' ) )
    end

    def test_update_with_bad_table
        begin
            update( "TABLE_NOT_INT_DB", { :id => 0 }, :value => 'more stuff' )
            fail
        rescue ODBC::Error
        end
    end

    def test_update_with_bad_column_header
        begin
            update( "TEST_TABLE", { :jimmy => 0 }, :value => 'more stuff' )
            fail
        rescue ODBC::Error
        end
    end

    def test_update_with_column_value_type
        begin
            update( "TEST_TABLE", { :id => 'bad' }, :value => 'more stuff' )
            fail
        rescue ODBC::Error
        end
    end

    def teardown
        $db.do( "TRUNCATE TABLE TEST_TABLE" )
        $db.do( "DROP TABLE TEST_TABLE" )
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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