Skip to content

Commit

Permalink
Update boutique-inventory exemplar in tests (#269)
Browse files Browse the repository at this point in the history
  • Loading branch information
jiegillet authored Mar 27, 2022
1 parent a57c971 commit c7eb9be
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion elixir
Submodule elixir updated 263 files
9 changes: 7 additions & 2 deletions test/elixir_analyzer/test_suite/boutique_inventory_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,16 @@ defmodule ElixirAnalyzer.ExerciseTest.BoutiqueInventoryTest do
Enum.filter(inventory, fn item -> Map.get(item, :price) == nil end)
end

def update_names(inventory, old_word, new_word) do
Enum.map(inventory, fn item ->
Map.update!(item, :name, fn name -> String.replace(name, old_word, new_word) end)
end)
end

def increase_quantity(item, count) do
Map.update(item, :quantity_by_size, %{}, fn quantity_by_size ->
quantity_by_size
|> Enum.map(fn {size, quantity} -> {size, quantity + count} end)
|> Enum.into(%{})
|> Map.new(fn {size, quantity} -> {size, quantity + count} end)
end)
end

Expand Down

0 comments on commit c7eb9be

Please sign in to comment.