test/test_adapter.rb in swift-0.13.0 vs test/test_adapter.rb in swift-0.14.0

- old
+ new

@@ -24,10 +24,16 @@ Swift.trace true, open('/dev/null', 'w') assert_block { @db.reconnect } Swift.trace false end + it 'records closed state' do + assert !Swift.db.closed? + Swift.db.close + assert Swift.db.closed? + end + describe 'execute' do it 'executes without bind values' do assert @db.execute %q{select count(*) from users} end @@ -112,14 +118,22 @@ it 'returns fields' do assert_equal [ :id, :name, :email, :created_at ], @res.fields end end + describe 'schema information' do + it 'should list tables' do + assert_equal %w(users), @db.tables + end - #-- - # TODO: Not sure how I feel about the block in write; feels like it's just there to get around the fields in the - # argument list. How about write('users', %w{name, email, balance}, data)? + it 'should list fields in a table with types' do + expect = {id: 'integer', name: 'text', email: 'text', created_at: 'timestamp'} + assert_equal expect, @db.fields('users') + end + end + + describe 'bulk writes!' do it 'writes from an IO object' do data = StringIO.new "Sally Arthurton\tsally@local\nJonas Arthurton\tjonas@local\n" assert_equal 2, @db.write('users', %w{name email}, data) end @@ -128,10 +142,10 @@ data = "Sally Arthurton\tsally@local\nJonas Arthurton\tjonas@local\n" assert_equal 2, @db.write('users', %w{name email}, data) end it 'writes with no columns specified' do - ts = DateTime.parse('2010-01-01 00:00:00').to_time + ts = DateTime.parse('2010-01-01 00:00:00') data = "1\tSally Arthurton\tsally@local\t#{ts}\n" row = {id: 1, name: 'Sally Arthurton', email: 'sally@local', created_at: ts} assert_equal 1, @db.write('users', [], data) assert_equal row, @db.execute('select * from users limit 1').first