-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from dwyl/testing
Testing
- Loading branch information
Showing
11 changed files
with
100 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
language: elixir | ||
elixir: | ||
- 1.8 | ||
env: | ||
- MIX_ENV=test | ||
script: | ||
- mix coveralls.json | ||
after_success: | ||
- bash <(curl -s https://codecov.io/bash) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"coverage_options": { | ||
"minimum_coverage": 95 | ||
}, | ||
"skip_files": [ | ||
"lib/store_finder/application.ex", | ||
"lib/store_finder/uk_postcodes.ex", | ||
"lib/store_finder_web.ex", | ||
"lib/store_finder_web/views/error_helpers", | ||
"test/*" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
..._finder_web/templates/page/store.html.eex → ...web/templates/page/nearby_stores.html.eex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
<h1>Nearby Stores</h1> | ||
<%= for {postcode, _lat, _long} <- @stores do %> | ||
<p><%= postcode %></p> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
defmodule StoreFinder.CreateStoresTest do | ||
use StoreFinderWeb.ConnCase | ||
alias StoreFinder.CreateStores | ||
|
||
describe "tests get_random_postcodes" do | ||
test "returns error messages when given incorrect value" do | ||
too_few = CreateStores.get_random_postcodes(-1) | ||
too_many = CreateStores.get_random_postcodes(200) | ||
string = CreateStores.get_random_postcodes("hello") | ||
|
||
assert too_few == "arg needs to be at least 1" | ||
assert too_many == "arg needs to be less than 200" | ||
assert string == "Need to pass integer" | ||
end | ||
|
||
test "returns a list of tuples when given int over 0" do | ||
stores = CreateStores.get_random_postcodes(1) | ||
|
||
assert is_list(stores) | ||
assert is_tuple(Enum.at(stores, 0)) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
defmodule StoreFinder.HaversineTest do | ||
use StoreFinderWeb.ConnCase | ||
alias StoreFinder.Haversine | ||
|
||
test "ets table exists when application starts" do | ||
stores = :ets.match_object(:store_cache, :_) | ||
assert is_list(stores) | ||
refute Enum.empty?(stores) | ||
end | ||
|
||
test "find_nearest_stores returns nearby stores" do | ||
ll = {51.563729, -0.107694} | ||
|
||
# becase I am using dummy data I know how many venues are in a 1km and 10km | ||
# radius of the given lat-long | ||
assert Haversine.find_nearest_stores(ll, 1) == [] | ||
assert Haversine.find_nearest_stores(ll, 10) |> length() == 5 | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters