-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from annatel/refacto
breaking change: queuetopia configuration
- Loading branch information
Showing
10 changed files
with
150 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
defmodule Queuetopia.Test.Assertions do | ||
import ExUnit.Assertions | ||
alias Queuetopia.Jobs.Job | ||
|
||
@doc """ | ||
Asserts the job has juste been created | ||
""" | ||
|
||
def assert_job_created(queue, %{} = params) do | ||
repo = queue.repo() | ||
|
||
job = | ||
Job | ||
|> Ecto.Query.last() | ||
|> repo.one() | ||
|
||
refute is_nil(job) && assert(^params = job) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
defmodule Queuetopia.Test.AssertionsTest do | ||
use Queuetopia.DataCase | ||
import Queuetopia.Test.Assertions | ||
|
||
describe "assert_job_created/0" do | ||
test "when the job has just been created" do | ||
scope = Queuetopia.TestQueuetopia.scope() | ||
queue = [scope] |> Module.safe_concat() | ||
|
||
job = Factory.insert(:job, scope: scope) | ||
|
||
assert_job_created(queue, Map.from_struct(job)) | ||
end | ||
|
||
test "when the job has not been created" do | ||
assert_raise ExUnit.AssertionError, fn -> | ||
scope = Queuetopia.TestQueuetopia.scope() | ||
queue = [scope] |> Module.safe_concat() | ||
|
||
job_params = Factory.params_for(:job) | ||
|
||
assert_job_created(queue, job_params) | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.