mirror of
https://github.com/hkalexling/Mango.git
synced 2025-08-03 11:25:29 -04:00
Use singleton in tests
This commit is contained in:
parent
7448592216
commit
30dea57346
@ -2,7 +2,7 @@ require "./spec_helper"
|
|||||||
|
|
||||||
describe Config do
|
describe Config do
|
||||||
it "creates config if it does not exist" do
|
it "creates config if it does not exist" do
|
||||||
with_default_config do |_, _, path|
|
with_default_config do |_, path|
|
||||||
File.exists?(path).should be_true
|
File.exists?(path).should be_true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
require "spec"
|
require "spec"
|
||||||
require "../src/context"
|
|
||||||
require "../src/server"
|
require "../src/server"
|
||||||
|
require "../src/config"
|
||||||
|
|
||||||
class State
|
class State
|
||||||
@@hash = {} of String => String
|
@@hash = {} of String => String
|
||||||
@ -37,15 +37,15 @@ end
|
|||||||
def with_default_config
|
def with_default_config
|
||||||
temp_config = get_tempfile "mango-test-config"
|
temp_config = get_tempfile "mango-test-config"
|
||||||
config = Config.load temp_config.path
|
config = Config.load temp_config.path
|
||||||
logger = Logger.new config.log_level
|
config.set_current
|
||||||
yield config, logger, temp_config.path
|
yield config, temp_config.path
|
||||||
temp_config.delete
|
temp_config.delete
|
||||||
end
|
end
|
||||||
|
|
||||||
def with_storage
|
def with_storage
|
||||||
with_default_config do |_, logger|
|
with_default_config do
|
||||||
temp_db = get_tempfile "mango-test-db"
|
temp_db = get_tempfile "mango-test-db"
|
||||||
storage = Storage.new temp_db.path, logger
|
storage = Storage.new temp_db.path
|
||||||
clear = yield storage, temp_db.path
|
clear = yield storage, temp_db.path
|
||||||
if clear == true
|
if clear == true
|
||||||
temp_db.delete
|
temp_db.delete
|
||||||
@ -54,9 +54,9 @@ def with_storage
|
|||||||
end
|
end
|
||||||
|
|
||||||
def with_queue
|
def with_queue
|
||||||
with_default_config do |_, logger|
|
with_default_config do
|
||||||
temp_queue_db = get_tempfile "mango-test-queue-db"
|
temp_queue_db = get_tempfile "mango-test-queue-db"
|
||||||
queue = MangaDex::Queue.new temp_queue_db.path, logger
|
queue = MangaDex::Queue.new temp_queue_db.path
|
||||||
clear = yield queue, temp_queue_db.path
|
clear = yield queue, temp_queue_db.path
|
||||||
if clear == true
|
if clear == true
|
||||||
temp_queue_db.delete
|
temp_queue_db.delete
|
||||||
|
Loading…
x
Reference in New Issue
Block a user