Skip to content

Instantly share code, notes, and snippets.

@shankardevy
Created July 15, 2017 05:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shankardevy/15fd2b108c01c03c2e9da81687b52019 to your computer and use it in GitHub Desktop.
Save shankardevy/15fd2b108c01c03c2e9da81687b52019 to your computer and use it in GitHub Desktop.
defmodule Mango.CatalogTest do
use Mango.DataCase
alias Mango.{Catalog, Repo}
alias Mango.Catalog.Product
setup do
Repo.insert %Product{ name: "Tomato", price: 55, sku: "A123", is_seasonal: false, category: "vegetables" }
Repo.insert %Product{ name: "Apple", price: 75, sku: "B232", is_seasonal: true, category: "fruits" }
:ok
end
test "list_products/0 returns all products" do
[p1 = %Product{}, p2 = %Product{}] = Catalog.list_products
assert p1.name == "Tomato"
assert p2.name == "Apple"
end
test "list_seasonal_products/0 return all seasonal products" do
[product = %Product{}] = Catalog.list_seasonal_products
assert product.name == "Apple"
end
test "get_category_products/1 returns products of the given category" do
[product = %Product{}] = Catalog.get_category_products("fruits")
assert product.name == "Apple"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment