Optionally pass in db path for testing

This commit is contained in:
Alex Ling 2020-05-07 09:21:41 +00:00
parent 049bd3ab2c
commit 7448592216
2 changed files with 6 additions and 4 deletions

View File

@ -80,7 +80,7 @@ module MangaDex
class Queue
property downloader : Downloader?
@path : String = Config.current.mangadex["download_queue_db_path"].to_s
@path : String
def self.default
unless @@default
@ -89,7 +89,8 @@ module MangaDex
@@default.not_nil!
end
def initialize
def initialize(db_path : String? = nil)
@path = db_path || Config.current.mangadex["download_queue_db_path"].to_s
dir = File.dirname @path
unless Dir.exists? dir
Logger.info "The queue DB directory #{dir} does not exist. " \

View File

@ -13,7 +13,7 @@ def verify_password(hash, pw)
end
class Storage
@path : String = Config.current.db_path
@path : String
def self.default
unless @@default
@ -22,7 +22,8 @@ class Storage
@@default.not_nil!
end
def initialize
def initialize(db_path : String? = nil)
@path = db_path || Config.current.db_path
dir = File.dirname @path
unless Dir.exists? dir
Logger.info "The DB directory #{dir} does not exist. " \