-
-
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.
- Loading branch information
1 parent
fd40590
commit 4278dc1
Showing
4 changed files
with
124 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
defmodule MishkaInstallerTest.PluginsManagement.EventTest do | ||
# Should be tested by mix test --trace --seed 0 | ||
use ExUnit.Case, async: false | ||
alias MishkaInstaller.PluginsManagement.Event | ||
|
||
################################################################################### | ||
########################## (▰˘◡˘▰) QueryTest (▰˘◡˘▰) ######################## | ||
################################################################################### | ||
describe "Event Table CRUD QueryTest ===>" do | ||
test "Create a Plugin record", _context do | ||
{:error, %{message: _msg, fields: [:extension, :event, :name]}} = assert Event.create(%{}) | ||
|
||
create = fn -> | ||
%{name: MishkaTest.Email, event: "after_login_test", extension: MishkaTest} | ||
|> Event.create() | ||
end | ||
|
||
{:ok, %Event{status: :registered, event: "after_login_test", name: MishkaTest.Email}} = | ||
assert create.() | ||
|
||
{:error, _error} = assert create.() | ||
end | ||
|
||
test "Read a Plugin/Plugins records", _context do | ||
assert Event.read(:all) != [] | ||
assert !is_nil(Event.read(name: MishkaTest.Email)) | ||
assert MishkaTest = List.first(Event.read(event: "after_login_test")).extension | ||
assert is_nil(Event.read(name: MishkaTest.Email1)) | ||
assert [] = Event.read(event: "after_login_test1") | ||
get_data = Event.read(:all) |> List.first() | ||
assert !is_nil(Event.read(get_data.id)) | ||
end | ||
|
||
test "Update a Plugin record", _context do | ||
get_data = Event.read(:all) |> List.first() | ||
{:ok, struct} = assert Event.update(Map.merge(get_data, %{priority: 50}), get_data.id) | ||
assert struct.priority == 50 | ||
get_data1 = Event.read(:all) |> List.first() | ||
assert get_data1.id == get_data.id | ||
{:ok, struct} = assert Event.update(:priority, 67, get_data.id) | ||
assert Event.read(struct.id).priority == 67 | ||
end | ||
|
||
test "All keys of plugins Record", _context do | ||
assert Event.records() != [] | ||
end | ||
|
||
test "Unique? plugin Record by name", _context do | ||
assert !Event.unique?(MishkaTest.Email) | ||
assert Event.unique?(MishkaTest.Email1) | ||
end | ||
|
||
test "Delete plugin Record", _context do | ||
get_data = Event.read(:all) |> List.first() | ||
{:ok, struct} = assert Event.delete(name: get_data.name) | ||
assert is_nil(Event.read(struct.id)) | ||
assert Event.read(:all) == [] | ||
end | ||
|
||
test "Drop all plugins records" do | ||
create = fn -> | ||
%{name: MishkaTest.Email, event: "after_login_test", extension: MishkaTest} | ||
|> Event.create() | ||
end | ||
|
||
{:ok, _struct} = assert create.() | ||
assert Event.read(:all) != [] | ||
{:ok, :atomic} = assert Event.drop() | ||
assert Event.read(:all) == [] | ||
end | ||
|
||
test "Check Hold statuses from plugins records" do | ||
create = fn name, status, deps -> | ||
%{name: name, extension: MishkaTest, depends: deps} | ||
|> Map.put(:event, "after_login_test") | ||
|> Map.put(:status, status) | ||
|> Event.create() | ||
end | ||
|
||
{:ok, struct} = | ||
assert create.(MishkaTest.Email, :registered, [ | ||
MishkaTest.Email1, | ||
MishkaTest.Email2, | ||
MishkaTest.Email3 | ||
]) | ||
|
||
assert length(Event.hold_statuses(struct.depends)) == 3 | ||
{:error, _error} = assert Event.hold_statuses?(struct.depends) | ||
|
||
create.(MishkaTest.Email1, :started, []) | ||
create.(MishkaTest.Email2, :started, []) | ||
create.(MishkaTest.Email3, :started, []) | ||
assert length(Event.hold_statuses(struct.depends)) == 0 | ||
:ok = assert Event.hold_statuses?(struct.depends) | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
defmodule MishkaInstallerTest.PluginsManagement.HookTest do | ||
# Should be tested by mix test --trace --seed 0 | ||
use ExUnit.Case, async: false | ||
# alias alias MishkaInstaller.PluginsManagement.Event | ||
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