Skip to content

Commit

Permalink
Merge pull request #27 from smartcitiesdata/event-stream
Browse files Browse the repository at this point in the history
Refactor to use new event structs
  • Loading branch information
jmorris-pillar authored Aug 23, 2019
2 parents eaa9ae4 + 7a8d858 commit 142f476
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ For more information about the `SmartCity.TestDataGenerator`, please see [https:
```elixir
def deps do
[
{:smart_city_test, "~> 0.3.5"}
{:smart_city_test, "~> 0.4.0"}
]
end
```
Expand Down
20 changes: 10 additions & 10 deletions lib/smart_city/test_data_generator.ex
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,20 @@ defmodule SmartCity.TestDataGenerator do
end

@doc """
Creates and returns a new `SmartCity.Dataset` example
Creates and returns a new `SmartCity.Event.DatasetUpdate` example
"""
@spec create_dataset(
%{
optional(:id) => String.t(),
optional(:business) => SmartCity.Dataset.Business,
optional(:technical) => SmartCity.Dataset.Technical
optional(:business) => SmartCity.Event.DatasetUpdate.Business,
optional(:technical) => SmartCity.Event.DatasetUpdate.Technical
}
| Enumerable.t()
) :: SmartCity.Dataset
) :: SmartCity.Event.DatasetUpdate
def create_dataset(%{} = overrides) when overrides == %{} do
{:ok, dataset} =
dataset_example()
|> (fn map -> apply(SmartCity.Dataset, :new, [map]) end).()
|> (fn map -> apply(SmartCity.Event.DatasetUpdate, :new, [map]) end).()

dataset
end
Expand All @@ -81,7 +81,7 @@ defmodule SmartCity.TestDataGenerator do
{:ok, dataset} =
dataset_example()
|> SmartCity.Helpers.deep_merge(overrides)
|> (fn map -> apply(SmartCity.Dataset, :new, [map]) end).()
|> (fn map -> apply(SmartCity.Event.DatasetUpdate, :new, [map]) end).()

dataset
end
Expand All @@ -105,7 +105,7 @@ defmodule SmartCity.TestDataGenerator do
end

@doc """
Creates and returns a new `SmartCity.Organization` example
Creates and returns a new `SmartCity.Event.OrganizationUpdate` example
"""
@spec create_organization(
%{
Expand All @@ -118,11 +118,11 @@ defmodule SmartCity.TestDataGenerator do
optional(:dn) => String.t()
}
| Enumerable.t()
) :: SmartCity.Organization
) :: SmartCity.Event.OrganizationUpdate
def create_organization(%{} = overrides) when overrides == %{} do
{:ok, organization} =
organization_example()
|> (fn map -> apply(SmartCity.Organization, :new, [map]) end).()
|> (fn map -> apply(SmartCity.Event.OrganizationUpdate, :new, [map]) end).()

organization
end
Expand All @@ -131,7 +131,7 @@ defmodule SmartCity.TestDataGenerator do
{:ok, organization} =
organization_example()
|> SmartCity.Helpers.deep_merge(overrides)
|> (fn map -> apply(SmartCity.Organization, :new, [map]) end).()
|> (fn map -> apply(SmartCity.Event.OrganizationUpdate, :new, [map]) end).()

organization
end
Expand Down
5 changes: 2 additions & 3 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule SmartCityTest.MixProject do
def project do
[
app: :smart_city_test,
version: "0.3.5",
version: "0.4.0",
elixir: "~> 1.8",
start_permanent: Mix.env() == :prod,
description: description(),
Expand All @@ -30,9 +30,8 @@ defmodule SmartCityTest.MixProject do
defp deps do
[
{:brod, "~> 3.8"},
{:smart_city, "~> 2.1"},
{:smart_city_data, "~> 3.0", only: [:test]},
{:smart_city_registry, "~> 4.0", only: [:test]},
{:smart_city, "~> 2.5"},
{:faker, "~> 0.12"},
{:ex_doc, "~> 0.19"},
{:credo, "~> 1.1", only: [:dev, :test, :integration], runtime: false},
Expand Down
5 changes: 3 additions & 2 deletions mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"brod": {:hex, :brod, "3.8.1", "74426e2d27989cd7f973599bc209c899dca8588068d27a2a37ca1b4bf8823c2a", [:make, :rebar, :rebar3], [{:kafka_protocol, "2.2.9", [hex: :kafka_protocol, repo: "hexpm", optional: false]}, {:supervisor3, "1.1.8", [hex: :supervisor3, repo: "hexpm", optional: false]}], "hexpm"},
"bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm"},
"crc32cer": {:hex, :crc32cer, "0.1.3", "8984906c4b4fae6aa292c48f286a1c83b19ad44bd102287acb94d696015967ce", [:make, :rebar, :rebar3], [], "hexpm"},
"credo": {:hex, :credo, "1.1.2", "02b6422f3e659eb74b05aca3c20c1d8da0119a05ee82577a82e6c2938bf29f81", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm"},
"credo": {:hex, :credo, "1.1.3", "bf31887b8914a4b7e1810ae2b5aab7c657698abbf4cca6a2335a094d57995168", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm"},
"dialyxir": {:hex, :dialyxir, "0.5.1", "b331b091720fd93e878137add264bac4f644e1ddae07a70bf7062c7862c4b952", [:mix], [], "hexpm"},
"earmark": {:hex, :earmark, "1.3.3", "5e8be428fcef362692b6dbd7dc55bdc7023da26d995cb3fb19aa4bd682bfd3f9", [:mix], [], "hexpm"},
"ex_doc": {:hex, :ex_doc, "0.21.1", "5ac36660846967cd869255f4426467a11672fec3d8db602c429425ce5b613b90", [:mix], [{:earmark, "~> 1.3", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm"},
Expand All @@ -12,10 +12,11 @@
"kafka_protocol": {:hex, :kafka_protocol, "2.2.9", "fbec2ddb607a0cb05b832a93dcfdd4dbae6bd3b838c9aace93f6871bbb91f81f", [:rebar, :rebar3], [{:crc32cer, "0.1.3", [hex: :crc32cer, repo: "hexpm", optional: false]}, {:snappyer, "1.2.4", [hex: :snappyer, repo: "hexpm", optional: false]}], "hexpm"},
"makeup": {:hex, :makeup, "1.0.0", "671df94cf5a594b739ce03b0d0316aa64312cee2574b6a44becb83cd90fb05dc", [:mix], [{:nimble_parsec, "~> 0.5.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm"},
"makeup_elixir": {:hex, :makeup_elixir, "0.14.0", "cf8b7c66ad1cff4c14679698d532f0b5d45a3968ffbcbfd590339cb57742f1ae", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm"},
"mime": {:hex, :mime, "1.3.1", "30ce04ab3175b6ad0bdce0035cba77bba68b813d523d1aac73d9781b4d193cf8", [:mix], [], "hexpm"},
"nimble_parsec": {:hex, :nimble_parsec, "0.5.0", "90e2eca3d0266e5c53f8fbe0079694740b9c91b6747f2b7e3c5d21966bba8300", [:mix], [], "hexpm"},
"patiently": {:hex, :patiently, "0.2.0", "67eb139591e10c4b363ae0198e832552f191c58894731efd3bf124ec4722267a", [:mix], [], "hexpm"},
"redix": {:hex, :redix, "0.10.2", "a9eabf47898aa878650df36194aeb63966d74f5bd69d9caa37babb32dbb93c5d", [:mix], [{:telemetry, "~> 0.4.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm"},
"smart_city": {:hex, :smart_city, "2.1.6", "88180173faa62032feddcc427d80465e056c46e8b17609a86633070ff44f86a1", [:mix], [], "hexpm"},
"smart_city": {:hex, :smart_city, "2.5.0", "31465a365110d3149592d94b0c589baf2de84223e7a9542ec518a898a9612878", [:mix], [{:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: false]}, {:mime, "~> 1.3", [hex: :mime, repo: "hexpm", optional: false]}], "hexpm"},
"smart_city_data": {:hex, :smart_city_data, "3.0.0", "e900472f98937b299ffa797cd8de8d24041c416b17b79d9497f7ec85264399c1", [:mix], [{:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: false]}, {:smart_city, "~> 2.1", [hex: :smart_city, repo: "hexpm", optional: false]}], "hexpm"},
"smart_city_registry": {:hex, :smart_city_registry, "4.0.0", "e3b86865b9c9340c15cfc93d7055249d1de85f53398ec3800d3d3b17b238f920", [:mix], [{:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: false]}, {:redix, "~> 0.9", [hex: :redix, repo: "hexpm", optional: false]}, {:smart_city, "~> 2.1", [hex: :smart_city, repo: "hexpm", optional: false]}], "hexpm"},
"snappyer": {:hex, :snappyer, "1.2.4", "6d739c534cd2339633127a2b40279be71f149e5842c5363a4d88e66efb7c1fec", [:make, :rebar, :rebar3], [], "hexpm"},
Expand Down
4 changes: 2 additions & 2 deletions test/smart_city/test_data_generator_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ defmodule SmartCity.TestDataGeneratorTest do
alias SmartCity.TestDataGenerator, as: TDG

test "create_dataset/1 creates a valid dataset" do
assert match?(%SmartCity.Dataset{}, TDG.create_dataset(%{}))
assert match?(%SmartCity.Event.DatasetUpdate{}, TDG.create_dataset(%{}))
end

test "create_organization/1 creates a valid organization" do
assert match?(%SmartCity.Organization{}, TDG.create_organization(%{}))
assert match?(%SmartCity.Event.OrganizationUpdate{}, TDG.create_organization(%{}))
end

test "create_data/1 creates valid data" do
Expand Down

0 comments on commit 142f476

Please sign in to comment.