Sha256: fcd370f05c0f83ddf1921f4e8336425185b48e1089b9f3acf01ca4f993e752da

Contents?: true

Size: 1.25 KB

Versions: 2

Compression:

Stored size: 1.25 KB

Contents

require 'test/unit'

class TestInsertOnMarjoree < 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 )" )
    end

    def test_insert
        assert( !contains?( "TEST_TABLE", :id => 2 ) )

        insert( "TEST_TABLE", :id => 2, :value => 12 )
        assert( contains?( "TEST_TABLE", :id => 2, :value => 12 ) )
    end

    def test_insert_with_bad_table
        begin
            insert( "TABLE_NOT_INT_DB", :id => 2, :value => 12 )
            fail
        rescue ODBC::Error
        end
    end

    def test_insert_with_bad_column_names
        begin
            insert( "TEST_TABLE", :fred => 2, :wilma => 12 )
            fail
        rescue ODBC::Error
        end
    end

    def test_insert_with_values_of_incorrect_type
        begin
            insert( "TEST_TABLE", :id => 'text', :value => 12 )
            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

2 entries across 2 versions & 1 rubygems

Version Path
marjoree-0.0.1 ./tests/test_insert.rb
marjoree-0.0.9 ./tests/marjoree/test_insert.rb