dotfiles/app/test/prymn/apps_test.exs
Nikos Papadakis 4a37cc402a
draft: apps
2023-11-20 18:50:24 +02:00

59 lines
1.6 KiB
Elixir

defmodule Prymn.AppsTest do
use Prymn.DataCase
alias Prymn.Apps
describe "apps" do
alias Prymn.Apps.App
import Prymn.AppsFixtures
@invalid_attrs %{name: nil}
test "list_apps/0 returns all apps" do
app = app_fixture()
assert Apps.list_apps() == [app]
end
test "get_app!/1 returns the app with given id" do
app = app_fixture()
assert Apps.get_app!(app.id) == app
end
test "create_app/1 with valid data creates a app" do
valid_attrs = %{name: "some name"}
assert {:ok, %App{} = app} = Apps.create_app(valid_attrs)
assert app.name == "some name"
end
test "create_app/1 with invalid data returns error changeset" do
assert {:error, %Ecto.Changeset{}} = Apps.create_app(@invalid_attrs)
end
test "update_app/2 with valid data updates the app" do
app = app_fixture()
update_attrs = %{name: "some updated name"}
assert {:ok, %App{} = app} = Apps.update_app(app, update_attrs)
assert app.name == "some updated name"
end
test "update_app/2 with invalid data returns error changeset" do
app = app_fixture()
assert {:error, %Ecto.Changeset{}} = Apps.update_app(app, @invalid_attrs)
assert app == Apps.get_app!(app.id)
end
test "delete_app/1 deletes the app" do
app = app_fixture()
assert {:ok, %App{}} = Apps.delete_app(app)
assert_raise Ecto.NoResultsError, fn -> Apps.get_app!(app.id) end
end
test "change_app/1 returns a app changeset" do
app = app_fixture()
assert %Ecto.Changeset{} = Apps.change_app(app)
end
end
end