tests: fix post and pool version tests helpers.
* Fix the pool version SQS service to always be mocked before every test. Before we had to manually set it up before every test dealing with pool versions. * Fix it so that we reconnect to the post/pool version databases before every test. Before using $ARCHIVE_DATABASE_URL to set the database url failed because environment variables weren't loaded by dotenv yet when connections were first established.
This commit is contained in:
@@ -3,10 +3,14 @@ class PoolVersion < ApplicationRecord
|
||||
belongs_to :pool
|
||||
|
||||
def self.enabled?
|
||||
Danbooru.config.aws_sqs_archives_url.present?
|
||||
Rails.env.test? || Danbooru.config.aws_sqs_archives_url.present?
|
||||
end
|
||||
|
||||
establish_connection (ENV["ARCHIVE_DATABASE_URL"] || "archive_#{Rails.env}".to_sym) if enabled?
|
||||
def self.database_url
|
||||
ENV["ARCHIVE_DATABASE_URL"] || "archive_#{Rails.env}".to_sym
|
||||
end
|
||||
|
||||
establish_connection database_url if enabled?
|
||||
|
||||
module SearchMethods
|
||||
def default_order
|
||||
|
||||
@@ -9,7 +9,11 @@ class PostVersion < ApplicationRecord
|
||||
Rails.env.test? || Danbooru.config.aws_sqs_archives_url.present?
|
||||
end
|
||||
|
||||
establish_connection (ENV["ARCHIVE_DATABASE_URL"] || "archive_#{Rails.env}".to_sym) if enabled?
|
||||
def self.database_url
|
||||
ENV["ARCHIVE_DATABASE_URL"] || "archive_#{Rails.env}".to_sym
|
||||
end
|
||||
|
||||
establish_connection database_url if enabled?
|
||||
|
||||
def self.check_for_retry(msg)
|
||||
if msg =~ /can't get socket descriptor/ && msg =~ /post_versions/
|
||||
|
||||
Reference in New Issue
Block a user