proposed_intent.test.exs (1812B)
1 # Zenflows is designed to implement the Valueflows vocabulary, 2 # written and maintained by srfsh <info@dyne.org>. 3 # Copyright (C) 2021-2023 Dyne.org foundation <foundation@dyne.org>. 4 # 5 # This program is free software: you can redistribute it and/or modify 6 # it under the terms of the GNU Affero General Public License as published by 7 # the Free Software Foundation, either version 3 of the License, or 8 # (at your option) any later version. 9 # 10 # This program is distributed in the hope that it will be useful, 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 # GNU Affero General Public License for more details. 14 # 15 # You should have received a copy of the GNU Affero General Public License 16 # along with this program. If not, see <https://www.gnu.org/licenses/>. 17 18 defmodule ZenflowsTest.VF.ProposedIntent do 19 use ZenflowsTest.Help.EctoCase, async: true 20 21 alias Zenflows.VF.ProposedIntent 22 23 setup do 24 %{params: %{ 25 reciprocal: Factory.bool(), 26 publishes_id: Factory.insert!(:intent).id, 27 published_in_id: Factory.insert!(:proposal).id, 28 }} 29 end 30 31 test "create ProposedIntent", %{params: params} do 32 assert {:ok, %ProposedIntent{} = prop_int} = 33 params 34 |> ProposedIntent.changeset() 35 |> Repo.insert() 36 37 assert prop_int.reciprocal == params.reciprocal 38 assert prop_int.publishes_id == params.publishes_id 39 assert prop_int.published_in_id == params.published_in_id 40 end 41 42 test "update ProposedIntent", %{params: params} do 43 assert {:ok, %ProposedIntent{} = prop_int} = 44 :proposed_intent 45 |> Factory.insert!() 46 |> ProposedIntent.changeset(params) 47 |> Repo.update() 48 49 assert prop_int.reciprocal == params.reciprocal 50 assert prop_int.publishes_id == params.publishes_id 51 assert prop_int.published_in_id == params.published_in_id 52 end 53 end