mirror of
https://github.com/hkalexling/Mango.git
synced 2025-08-02 10:55:30 -04:00
Remove MangaDex module tests
This commit is contained in:
parent
8d99400c5f
commit
f7004549b8
@ -1,104 +0,0 @@
|
|||||||
require "./spec_helper"
|
|
||||||
|
|
||||||
include MangaDex
|
|
||||||
|
|
||||||
describe Queue do
|
|
||||||
it "creates DB at given path" do
|
|
||||||
with_queue do |_, path|
|
|
||||||
File.exists?(path).should be_true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
it "pops nil when empty" do
|
|
||||||
with_queue do |queue|
|
|
||||||
queue.pop.should be_nil
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
it "inserts multiple jobs" do
|
|
||||||
with_queue do |queue|
|
|
||||||
j1 = Job.new "1", "1", "title", "manga_title", JobStatus::Error,
|
|
||||||
Time.utc
|
|
||||||
j2 = Job.new "2", "2", "title", "manga_title", JobStatus::Completed,
|
|
||||||
Time.utc
|
|
||||||
j3 = Job.new "3", "3", "title", "manga_title", JobStatus::Pending,
|
|
||||||
Time.utc
|
|
||||||
j4 = Job.new "4", "4", "title", "manga_title",
|
|
||||||
JobStatus::Downloading, Time.utc
|
|
||||||
count = queue.push [j1, j2, j3, j4]
|
|
||||||
count.should eq 4
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
it "pops pending job" do
|
|
||||||
with_queue do |queue|
|
|
||||||
job = queue.pop
|
|
||||||
job.should_not be_nil
|
|
||||||
job.not_nil!.id.should eq "3"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
it "correctly counts jobs" do
|
|
||||||
with_queue do |queue|
|
|
||||||
queue.count.should eq 4
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
it "deletes job" do
|
|
||||||
with_queue do |queue|
|
|
||||||
queue.delete "4"
|
|
||||||
queue.count.should eq 3
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
it "sets status" do
|
|
||||||
with_queue do |queue|
|
|
||||||
job = queue.pop.not_nil!
|
|
||||||
queue.set_status JobStatus::Downloading, job
|
|
||||||
job = queue.pop
|
|
||||||
job.should_not be_nil
|
|
||||||
job.not_nil!.status.should eq JobStatus::Downloading
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
it "sets number of pages" do
|
|
||||||
with_queue do |queue|
|
|
||||||
job = queue.pop.not_nil!
|
|
||||||
queue.set_pages 100, job
|
|
||||||
job = queue.pop
|
|
||||||
job.should_not be_nil
|
|
||||||
job.not_nil!.pages.should eq 100
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
it "adds fail/success counts" do
|
|
||||||
with_queue do |queue|
|
|
||||||
job = queue.pop.not_nil!
|
|
||||||
queue.add_success job
|
|
||||||
queue.add_success job
|
|
||||||
queue.add_fail job
|
|
||||||
job = queue.pop
|
|
||||||
job.should_not be_nil
|
|
||||||
job.not_nil!.success_count.should eq 2
|
|
||||||
job.not_nil!.fail_count.should eq 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
it "appends status message" do
|
|
||||||
with_queue do |queue|
|
|
||||||
job = queue.pop.not_nil!
|
|
||||||
queue.add_message "hello", job
|
|
||||||
queue.add_message "world", job
|
|
||||||
job = queue.pop
|
|
||||||
job.should_not be_nil
|
|
||||||
job.not_nil!.status_message.should eq "\nhello\nworld"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
it "cleans up" do
|
|
||||||
with_queue do
|
|
||||||
true
|
|
||||||
end
|
|
||||||
State.reset
|
|
||||||
end
|
|
||||||
end
|
|
@ -1,4 +1,5 @@
|
|||||||
require "spec"
|
require "spec"
|
||||||
|
require "../src/queue"
|
||||||
require "../src/server"
|
require "../src/server"
|
||||||
require "../src/config"
|
require "../src/config"
|
||||||
|
|
||||||
@ -52,14 +53,3 @@ def with_storage
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def with_queue
|
|
||||||
with_default_config do
|
|
||||||
temp_queue_db = get_tempfile "mango-test-queue-db"
|
|
||||||
queue = MangaDex::Queue.new temp_queue_db.path
|
|
||||||
clear = yield queue, temp_queue_db.path
|
|
||||||
if clear == true
|
|
||||||
temp_queue_db.delete
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user