Better state management in spec and add some tests for MangaDex::Queue

This commit is contained in:
Alex Ling
2020-03-03 18:34:39 +00:00
parent 9ffe896705
commit 1abdac2fdd
4 changed files with 183 additions and 56 deletions
+40
View File
@@ -0,0 +1,40 @@
require "./spec_helper"
include MangaDex
describe Queue do
it "creates DB at given path" do
with_queue do |queue, path|
File.exists?(path).should be_true
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 "0", "0", "title", "manga_title", JobStatus::Pending,
Time.utc
count = queue.push [j1, j2, j3]
count.should eq 3
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 "0"
end
end
it "cleans up" do
State.reset
with_queue do
true
end
end
end