Skip to content

Commit 1e9ee2f

Browse files
committed
Fix rubocop offenses in test_bind_with_time
Split test_bind_with_time into four separate tests to fix: - Metrics/AbcSize: Assignment Branch Condition size too high [32.06/17] - Metrics/MethodLength: Method has too many lines [11/10] - Minitest/MultipleAssertions: Test case has too many assertions [4/3] New tests: - test_bind_with_time: Tests binding with Time object (exact match) - test_bind_with_time_microseconds: Tests binding with microseconds - test_bind_with_time_now: Tests binding with current time - test_bind_with_time_string: Tests binding with time string value All tests pass successfully.
1 parent c49c324 commit 1e9ee2f

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

test/duckdb_test/prepared_statement_test.rb

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -800,22 +800,36 @@ def test_bind_with_varchar
800800
end
801801

802802
def test_bind_with_time
803-
now = Time.now
804803
stmt = DuckDB::PreparedStatement.new(@con, 'SELECT * FROM a WHERE col_timestamp = $1')
805804

806805
stmt.bind(1, Time.mktime(2019, 11, 9, 12, 34, 56, 0))
807806

808807
assert_equal(expected_row, stmt.execute.each.first)
808+
end
809+
810+
def test_bind_with_time_microseconds
811+
stmt = DuckDB::PreparedStatement.new(@con, 'SELECT * FROM a WHERE col_timestamp = $1')
809812

810813
stmt.bind(1, Time.mktime(2019, 11, 9, 12, 34, 56, 123_456))
811814

812815
assert_nil(stmt.execute.each.first)
816+
end
817+
818+
def test_bind_with_time_now
819+
now = Time.now
820+
stmt = DuckDB::PreparedStatement.new(@con, 'SELECT * FROM a WHERE col_timestamp = $1')
813821

814822
@con.query("UPDATE a SET col_timestamp = '#{now.strftime('%Y/%m/%d %H:%M:%S.%N')}'")
815823
stmt.bind(1, now)
816824

817825
assert_equal(1, stmt.execute.each.first.first)
826+
end
827+
828+
def test_bind_with_time_string
829+
now = Time.now
830+
stmt = DuckDB::PreparedStatement.new(@con, 'SELECT * FROM a WHERE col_timestamp = $1')
818831

832+
@con.query("UPDATE a SET col_timestamp = '#{now.strftime('%Y/%m/%d %H:%M:%S.%N')}'")
819833
stmt.bind(1, now.strftime('%Y/%m/%d %H:%M:%S') + ".#{now.nsec + 1_000_000}")
820834

821835
assert_nil(stmt.execute.each.first)

0 commit comments

Comments
 (0)