From 192c25c9a9d9a675a91fcaa6d122e20dd205ab7d Mon Sep 17 00:00:00 2001 From: shibao Date: Fri, 10 Sep 2021 00:26:07 -0400 Subject: [PATCH] fixup! add invite model --- test/cannery/accounts_test.exs | 61 ++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/test/cannery/accounts_test.exs b/test/cannery/accounts_test.exs index 4ded6a94..85e85573 100644 --- a/test/cannery/accounts_test.exs +++ b/test/cannery/accounts_test.exs @@ -1505,4 +1505,65 @@ defmodule Cannery.AccountsTest do refute inspect(%User{password: "123456"}) =~ "password: \"123456\"" end end + + describe "invites" do + alias Cannery.Accounts.Invite + + @valid_attrs %{name: "some name", token: "some token"} + @update_attrs %{name: "some updated name", token: "some updated token"} + @invalid_attrs %{name: nil, token: nil} + + def invite_fixture(attrs \\ %{}) do + {:ok, invite} = + attrs + |> Enum.into(@valid_attrs) + |> Accounts.create_invite() + + invite + end + + test "list_invites/0 returns all invites" do + invite = invite_fixture() + assert Accounts.list_invites() == [invite] + end + + test "get_invite!/1 returns the invite with given id" do + invite = invite_fixture() + assert Accounts.get_invite!(invite.id) == invite + end + + test "create_invite/1 with valid data creates a invite" do + assert {:ok, %Invite{} = invite} = Accounts.create_invite(@valid_attrs) + assert invite.name == "some name" + assert invite.token == "some token" + end + + test "create_invite/1 with invalid data returns error changeset" do + assert {:error, %Ecto.Changeset{}} = Accounts.create_invite(@invalid_attrs) + end + + test "update_invite/2 with valid data updates the invite" do + invite = invite_fixture() + assert {:ok, %Invite{} = invite} = Accounts.update_invite(invite, @update_attrs) + assert invite.name == "some updated name" + assert invite.token == "some updated token" + end + + test "update_invite/2 with invalid data returns error changeset" do + invite = invite_fixture() + assert {:error, %Ecto.Changeset{}} = Accounts.update_invite(invite, @invalid_attrs) + assert invite == Accounts.get_invite!(invite.id) + end + + test "delete_invite/1 deletes the invite" do + invite = invite_fixture() + assert {:ok, %Invite{}} = Accounts.delete_invite(invite) + assert_raise Ecto.NoResultsError, fn -> Accounts.get_invite!(invite.id) end + end + + test "change_invite/1 returns a invite changeset" do + invite = invite_fixture() + assert %Ecto.Changeset{} = Accounts.change_invite(invite) + end + end end