68 lines
1.9 KiB
Elixir
68 lines
1.9 KiB
Elixir
|
defmodule Eventos.ActorsTest do
|
||
|
use Eventos.DataCase
|
||
|
|
||
|
alias Eventos.Actors
|
||
|
|
||
|
describe "bots" do
|
||
|
alias Eventos.Actors.Bot
|
||
|
|
||
|
@valid_attrs %{source: "some source", type: "some type"}
|
||
|
@update_attrs %{source: "some updated source", type: "some updated type"}
|
||
|
@invalid_attrs %{source: nil, type: nil}
|
||
|
|
||
|
def bot_fixture(attrs \\ %{}) do
|
||
|
{:ok, bot} =
|
||
|
attrs
|
||
|
|> Enum.into(@valid_attrs)
|
||
|
|> Actors.create_bot()
|
||
|
|
||
|
bot
|
||
|
end
|
||
|
|
||
|
test "list_bots/0 returns all bots" do
|
||
|
bot = bot_fixture()
|
||
|
assert Actors.list_bots() == [bot]
|
||
|
end
|
||
|
|
||
|
test "get_bot!/1 returns the bot with given id" do
|
||
|
bot = bot_fixture()
|
||
|
assert Actors.get_bot!(bot.id) == bot
|
||
|
end
|
||
|
|
||
|
test "create_bot/1 with valid data creates a bot" do
|
||
|
assert {:ok, %Bot{} = bot} = Actors.create_bot(@valid_attrs)
|
||
|
assert bot.source == "some source"
|
||
|
assert bot.type == "some type"
|
||
|
end
|
||
|
|
||
|
test "create_bot/1 with invalid data returns error changeset" do
|
||
|
assert {:error, %Ecto.Changeset{}} = Actors.create_bot(@invalid_attrs)
|
||
|
end
|
||
|
|
||
|
test "update_bot/2 with valid data updates the bot" do
|
||
|
bot = bot_fixture()
|
||
|
assert {:ok, bot} = Actors.update_bot(bot, @update_attrs)
|
||
|
assert %Bot{} = bot
|
||
|
assert bot.source == "some updated source"
|
||
|
assert bot.type == "some updated type"
|
||
|
end
|
||
|
|
||
|
test "update_bot/2 with invalid data returns error changeset" do
|
||
|
bot = bot_fixture()
|
||
|
assert {:error, %Ecto.Changeset{}} = Actors.update_bot(bot, @invalid_attrs)
|
||
|
assert bot == Actors.get_bot!(bot.id)
|
||
|
end
|
||
|
|
||
|
test "delete_bot/1 deletes the bot" do
|
||
|
bot = bot_fixture()
|
||
|
assert {:ok, %Bot{}} = Actors.delete_bot(bot)
|
||
|
assert_raise Ecto.NoResultsError, fn -> Actors.get_bot!(bot.id) end
|
||
|
end
|
||
|
|
||
|
test "change_bot/1 returns a bot changeset" do
|
||
|
bot = bot_fixture()
|
||
|
assert %Ecto.Changeset{} = Actors.change_bot(bot)
|
||
|
end
|
||
|
end
|
||
|
end
|