Skip to content

Commit 10cc67f

Browse files
committed
Coerce foreign key test for SQL Server error message
1 parent 97b3262 commit 10cc67f

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

test/cases/coerced_tests.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -977,6 +977,19 @@ def test_add_on_delete_restrict_foreign_key_coerced
977977
@connection.add_foreign_key :astronauts, :rockets, column: "rocket_id", on_update: :restrict
978978
end
979979
end
980+
981+
# Error message depends on the database adapter.
982+
coerce_tests! :test_add_foreign_key_with_if_not_exists_not_set
983+
def test_add_foreign_key_with_if_not_exists_not_set_coerced
984+
@connection.add_foreign_key :astronauts, :rockets
985+
assert_equal 1, @connection.foreign_keys("astronauts").size
986+
987+
error = assert_raises do
988+
@connection.add_foreign_key :astronauts, :rockets
989+
end
990+
991+
assert_match(/TinyTds::Error: There is already an object named '.*' in the database/, error.message)
992+
end
980993
end
981994
end
982995
end

0 commit comments

Comments
 (0)