PageRenderTime 48ms CodeModel.GetById 8ms RepoModel.GetById 1ms app.codeStats 0ms

/test/postgres_simple_test.rb

https://github.com/ystael/activerecord-jdbc-adapter
Ruby | 65 lines | 47 code | 11 blank | 7 comment | 0 complexity | ddb130e9ab4c6b8f4584a74087a72ce4 MD5 | raw file
Possible License(s): 0BSD
  1. # To run this script, set up the following postgres user and database:
  2. #
  3. # sudo -u postgres createuser -D -A -P blog
  4. # sudo -u postgres createdb -O blog weblog_development
  5. #
  6. require 'jdbc_common'
  7. require 'db/postgres'
  8. class PostgresSimpleTest < Test::Unit::TestCase
  9. include SimpleTestMethods
  10. include ActiveRecord3TestMethods
  11. def test_multi_statement_support
  12. results = @connection.execute "SELECT title from entries; SELECT login from users"
  13. assert_equal 2, results.length
  14. assert_equal ["title"], results[0].first.keys
  15. assert_equal ["login"], results[1].first.keys
  16. end
  17. end
  18. class PostgresDeserializationTest < Test::Unit::TestCase
  19. def setup
  20. DbTypeMigration.up
  21. end
  22. def teardown
  23. DbTypeMigration.down
  24. end
  25. def test_should_keep_float_precision
  26. expected = DbType.create(:sample_float => 7.3)
  27. actual = DbType.find(expected.id)
  28. assert_equal expected.sample_float, actual.sample_float
  29. end
  30. end
  31. class PostgresSchemaDumperTest < Test::Unit::TestCase
  32. def setup
  33. DbTypeMigration.up
  34. @connection = ActiveRecord::Base.connection
  35. strio = StringIO.new
  36. ActiveRecord::SchemaDumper::dump(ActiveRecord::Base.connection, strio)
  37. @dump = strio.string
  38. end
  39. def teardown
  40. DbTypeMigration.down
  41. end
  42. # http://kenai.com/jira/browse/ACTIVERECORD_JDBC-135
  43. def test_schema_dump_should_not_have_limits_on_boolean
  44. lines = @dump.grep(/boolean/)
  45. assert !lines.empty?
  46. lines.each {|line| assert line !~ /limit/ }
  47. end
  48. # http://kenai.com/jira/browse/ACTIVERECORD_JDBC-139
  49. def test_schema_dump_should_not_have_limits_on_text_or_date
  50. lines = @dump.grep(/date|text/)
  51. assert !lines.empty?
  52. lines.each {|line| assert line !~ /limit/ }
  53. end
  54. end