From 372547b31b51d871f104ae5679e98420a99a12c1 Mon Sep 17 00:00:00 2001 From: Patrick J Cherry Date: Mon, 30 Apr 2012 12:49:24 +0100 Subject: Non-UTF8 stuff is now stripped. Added encoding tests. --- test/tc_mauve_database_peculiarities.rb | 85 +++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 test/tc_mauve_database_peculiarities.rb (limited to 'test') diff --git a/test/tc_mauve_database_peculiarities.rb b/test/tc_mauve_database_peculiarities.rb new file mode 100644 index 0000000..9eb612e --- /dev/null +++ b/test/tc_mauve_database_peculiarities.rb @@ -0,0 +1,85 @@ +$:.unshift "../lib" + +require 'th_mauve' +require 'mauve/datamapper' +require 'mauve/server' +require 'mauve/configuration' +require 'mauve/configuration_builder' +require 'mauve/configuration_builders' +require 'iconv' + +class TcMauveDatabasePeculiarities < Mauve::UnitTest + include Mauve + + def setup + super + setup_database + @temp_db = "mauve_test.#{10.times.collect{ rand(36).to_s(36) }.join}" + end + + def teardown + teardown_database + super + end + + def test_encoding + # + # Don't test unless the DB URL has been set. + # + return unless @db_url + + config=< "#{lang}:#{enc}", + :source => "test", + :subject => str + ) + + assert_nothing_raised("failed to insert #{enc}") { alert.save } + end + end + end +end + + + +class TcMauveDatabasePostgresPeculiarities < TcMauveDatabasePeculiarities + def setup + super + system("createdb #{@temp_db} --encoding UTF8") || flunk("Failed to create #{@temp_db}") + # @pg_conn = PGconn.open(:dbname => @temp_db) + @db_url = "postgres:///#{@temp_db}" + end + + def teardown + # @pg_conn.finish if @pg_conn.is_a?(PGconn) and @pg_conn.status == PGconn::CONNECTION_OK + super + (system("dropdb #{@temp_db}") || puts("Failed to drop #{@temp_db}")) if @temp_db + end +end + +class TcMauveDatabaseSqlite3Peculiarities < TcMauveDatabasePeculiarities + def setup + super + # @pg_conn = PGconn.open(:dbname => @temp_db) + @db_url = "sqlite3::memory:" + end +end + -- cgit v1.2.1