1
0
mirror of https://github.com/mgerb/classic-wow-forums synced 2026-01-11 01:22:49 +00:00

figuring out testing - works pretty good so far

This commit is contained in:
2018-01-04 23:04:39 -06:00
parent f540e7351b
commit 006a7e1fc2
7 changed files with 138 additions and 7 deletions

View File

@@ -0,0 +1,49 @@
defmodule MyApp.Data.UserTest do
use MyAppWeb.ConnCase, async: true
import MyApp.Data.User
import MyApp.Data.TestHelpers
test "user is inserted into database" do
{:ok, user} = new_user()
assert user == %{
access_token: "test_token",
battle_net_id: 1,
battletag: "mgerb42",
id: user.id,
permissions: "user",
}
end
test "user's battletag is updated" do
{:ok, user} = new_user()
# update user battletag
user = user
|> atom_key_to_string()
|> Map.put("battletag", "mgerb")
{:ok, user} = upsert_user(user)
assert user == %{
access_token: "test_token",
battle_net_id: 1,
battletag: "mgerb",
id: user.id,
permissions: "user",
}
# call upsert again with same battletag
{:ok, user} = user
|> atom_key_to_string()
|> upsert_user()
assert user == %{
access_token: "test_token",
battle_net_id: 1,
battletag: "mgerb",
id: user.id,
permissions: "user",
}
end
end