Commit 0402e77a authored by Joe Libipl's avatar Joe Libipl

Move DB-specific code out of hooks.

parent d6201bc5
def delete_all_test_accounts()
client = connect_to_db(@server_database)
result = client.execute("DELETE
FROM [#{@server_database}].[dbo].[Account]
WHERE account LIKE 'test%'
AND email LIKE '%301days.com'")
debug_msg "Rows deleted from [Account]: #{result.do}"
end
......@@ -23,3 +23,10 @@ def log_contains_immediate(message, logtype = 'SystemGo')
rows_affected = result.do
rows_affected > 0
end
def clear_log()
client = connect_to_db(@server_database)
result = client.execute("DELETE
FROM [#{@server_database}].[dbo].[Log]")
debug_msg "Rows deleted from [Log]: #{result.do}"
end
......@@ -58,6 +58,22 @@ def player_exists(player_hash)
result.affected_rows > 0
end
def delete_all_test_players()
client = connect_to_db(@server_database)
player_tables = ["PlayerBelt","PlayerEffects","PlayerFlags","PlayerHeld","PlayerLocker",
"PlayerQuests","PlayerRings","PlayerSack","PlayerSettings","PlayerSkills","PlayerSpells",
"PlayerWearing","Player"]
get_all_test_player_ids().each do |player_to_delete|
debug_msg "Deleting player #{player_to_delete}"
player_tables.each do |table|
result = client.execute("DELETE
FROM [#{@server_database}].[dbo].[#{table}]
WHERE playerID = '#{player_to_delete}'")
debug_msg "Rows deleted from [#{table}]: #{result.do}"
end
end
end
def get_all_test_player_ids()
id_list = []
client = connect_to_db(@server_database)
......
......@@ -41,25 +41,7 @@ After('@kill_server_after') do |scenario|
end
After('@db_cleanup') do |scenario|
client = connect_to_db(@server_database)
result = client.execute("DELETE
FROM [#{@server_database}].[dbo].[Account]
WHERE account LIKE 'test%'
AND email LIKE '%301days.com'")
debug_msg "Rows deleted from [Account]: #{result.do}"
player_tables = ["PlayerBelt","PlayerEffects","PlayerFlags","PlayerHeld","PlayerLocker",
"PlayerQuests","PlayerRings","PlayerSack","PlayerSettings","PlayerSkills","PlayerSpells",
"PlayerWearing","Player"]
get_all_test_player_ids().each do |player_to_delete|
debug_msg "Deleting player #{player_to_delete}"
player_tables.each do |table|
result = client.execute("DELETE
FROM [#{@server_database}].[dbo].[#{table}]
WHERE playerID = '#{player_to_delete}'")
debug_msg "Rows deleted from [#{table}]: #{result.do}"
end
end
result = client.execute("DELETE
FROM [#{@server_database}].[dbo].[Log]")
debug_msg "Rows deleted from [Log]: #{result.do}"
delete_all_test_accounts()
delete_all_test_players()
clear_log()
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment