Skip to content

Commit

Permalink
update seeds.exs to use Item.create_item/1 instead of Repo.insert!/1 …
Browse files Browse the repository at this point in the history
…to enusre the item.cid is created for testing #410
  • Loading branch information
nelsonic committed Sep 10, 2023
1 parent 2e6c4ee commit 7e306d6
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions priv/repo/seeds.exs
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,32 @@ if env == :test || env == :dev do
Repo.delete_all(Item)
Repo.delete_all(Tag)

# Create "all"" List!
{:ok, %{model: _all_list}} =
App.List.create_list(%{name: "all", person_id: person_id, status: 2})

# Create a few items for testing on localhost
item0 =
Repo.insert!(%Item{person_id: person_id, text: "Use the MVP!", status: 3})
{:ok, %{model: item0}} =
Item.create_item(%{person_id: person_id, text: "Use the MVP!", status: 3})

item1 =
Repo.insert!(%Item{person_id: person_id, text: "Buy Bananas", status: 2})
{:ok, %{model: item1}} =
Item.create_item(%{person_id: person_id, text: "Buy Bananas", status: 2})

item2 =
Repo.insert!(%Item{
{:ok, %{model: item2}} = Item.create_item(%{
person_id: person_id,
text: "Make Banana Muffins",
status: 2
})

item3 =
Repo.insert!(%Item{
{:ok, %{model: item3}} = Item.create_item(%{
person_id: person_id,
text: "Eat Banana Muffin!",
status: 2
})

item4 =
Repo.insert!(%Item{person_id: person_id, text: "Go to Shops", status: 2})
{:ok, %{model: item4}} = Item.create_item(%{
person_id: person_id, text: "Go to Shops", status: 2
})

# Tags
tag0 =
Expand Down Expand Up @@ -73,13 +76,9 @@ if env == :test || env == :dev do
{:ok, _timer1} =
Timer.start(%{item_id: item0.id, person_id: person_id, start: started})

# Create "all"" List!
{:ok, %{model: _all_list}} =
App.List.create_list(%{name: "all", person_id: person_id, status: 2})

# Add Cid to all existing items before adding them to the "all" list:
App.Item.update_all_items_cid()

# Add items to lists:
App.List.add_all_items_to_all_list_for_person_id(person_id)
# App.List.add_all_items_to_all_list_for_person_id(person_id)
end

0 comments on commit 7e306d6

Please sign in to comment.