Skip to content

Commit

Permalink
add test for time conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Peckham committed Sep 14, 2011
1 parent d6d2bcb commit 690b23b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
5 changes: 3 additions & 2 deletions test/fixtures/seed_integration_tests.sql
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,10 @@ CREATE TABLE test_datetime_conversion (
column_b TIMESTAMP,
column_c DATETIME DEFAULT '0000-00-00',
column_d DATETIME DEFAULT '0000-00-00 00:00',
column_e DATETIME DEFAULT '0000-00-00 00:00:00'
column_e DATETIME DEFAULT '0000-00-00 00:00:00',
column_f TIME
);
INSERT INTO test_datetime_conversion (column_a) VALUES ('0000-00-00 00:00');
INSERT INTO test_datetime_conversion (column_a, column_f) VALUES ('0000-00-00 00:00', '08:15:30');

DROP TABLE IF EXISTS test_index_conversion;
CREATE TABLE test_index_conversion (column_a VARCHAR(10));
Expand Down
11 changes: 8 additions & 3 deletions test/integration/convert_to_db_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ def test_null_conversion
end

def test_datetime_conversion
result = exec_sql_on_psql('SELECT column_a FROM test_datetime_conversion').first
result = exec_sql_on_psql('SELECT column_a, column_f FROM test_datetime_conversion').first
assert_equal '1970-01-01 00:00:00', result['column_a']
assert_equal '08:15:30', result['column_f']
end

def test_datetime_defaults
Expand All @@ -72,10 +73,14 @@ def test_datetime_defaults
WHERE a.attrelid = 'test_datetime_conversion'::regclass AND a.attnum > 0
SQL

assert_equal 5, result.count
assert_equal 6, result.count

result.each do |row|
assert_equal "timestamp without time zone", row["format_type"]
if row["attname"] == "column_f"
assert_equal "time without time zone", row["format_type"]
else
assert_equal "timestamp without time zone", row["format_type"]
end

case row["attname"]
when "column_a"
Expand Down

0 comments on commit 690b23b

Please sign in to comment.