-
Notifications
You must be signed in to change notification settings - Fork 0
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
7cbe38e
commit 410d094
Showing
3 changed files
with
50 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
defmodule UserPreferences.ActivityServer.Test do | ||
use ExUnit.Case | ||
alias ActivityServer | ||
|
||
describe "ActivityServer" do | ||
test "returns count for existing resolver" do | ||
key = "get_all_users" | ||
assert {:ok, 0} = GenServer.whereis(ActivityServer) |> GenServer.call({:get, key}) | ||
end | ||
|
||
test "returns error for non-existing resolver" do | ||
key = "burn_all_ships" | ||
{:error, msg} = GenServer.whereis(ActivityServer) |> GenServer.call({:get, key}) | ||
assert msg == "Requested key: #{key} is invalid" | ||
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
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,31 @@ | ||
defmodule UserPreferences.ActivityMonitorTest do | ||
use ExUnit.Case, async: true | ||
alias UserPreferencesWeb.Schema | ||
|
||
@get_resolver_hits """ | ||
query getResolverHits($key: String){ | ||
resolverHits(key: $key) | ||
} | ||
""" | ||
|
||
describe "@resolverHits" do | ||
test "returns the count for a resolver" do | ||
key = "get_all_users" | ||
|
||
assert {:ok, %{data: %{"resolverHits" => count}}} = | ||
Absinthe.run(@get_resolver_hits, Schema, variables: %{"key" => key}) | ||
|
||
assert count === 0 | ||
end | ||
|
||
test "returns" do | ||
key = "not_a_key" | ||
|
||
assert {:ok, %{data: %{"resolverHits" => count}, errors: errors}} = | ||
Absinthe.run(@get_resolver_hits, Schema, variables: %{"key" => key}) | ||
|
||
assert is_nil(count) === true | ||
assert List.first(errors).message === "Requested key: #{key} is invalid" | ||
end | ||
end | ||
end |