From f9f65c607800dc03b3ec5e65181f133c762e2e79 Mon Sep 17 00:00:00 2001 From: Matthew Boehlig Date: Sat, 8 Apr 2023 15:32:52 -0500 Subject: [PATCH 1/3] fix factory prop with single key --- apps/blunt_data/lib/blunt/data/factories/values/prop.ex | 5 ----- apps/blunt_data/test/blunt/data/factories_test.exs | 8 ++++++++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/apps/blunt_data/lib/blunt/data/factories/values/prop.ex b/apps/blunt_data/lib/blunt/data/factories/values/prop.ex index 7ee5e0e..5f1820e 100644 --- a/apps/blunt_data/lib/blunt/data/factories/values/prop.ex +++ b/apps/blunt_data/lib/blunt/data/factories/values/prop.ex @@ -21,11 +21,6 @@ defmodule Blunt.Data.Factories.Values.Prop do value = Factory.log_value(current_factory, [], field, lazy, "prop") put_values(acc, field, value, opts) - [path] -> - value = get_in(acc, Access.key(path)) - value = Factory.log_value(current_factory, value, field, lazy, "prop") - put_values(acc, field, value, opts) - [head | rest] -> # ensure that the first key in the path is not nil acc = diff --git a/apps/blunt_data/test/blunt/data/factories_test.exs b/apps/blunt_data/test/blunt/data/factories_test.exs index 0bb95a1..35d6852 100644 --- a/apps/blunt_data/test/blunt/data/factories_test.exs +++ b/apps/blunt_data/test/blunt/data/factories_test.exs @@ -46,12 +46,20 @@ defmodule Blunt.Data.FactoriesTest do prop :name, [:person, :name] end + factory FactoryWithValuesMessage, as: :single_key_prop do + const :dog, "corn" + prop :id, [:person, :id] + prop :name, [:dog] + end + test "factory values" do id = UUID.uuid4() person = %{id: id, name: "chris", dog: "maize"} assert %FactoryWithValuesMessage{id: ^id, name: "chris", dog: "maize"} = build(:my_message, person: person) + + assert %FactoryWithValuesMessage{id: ^id, name: "corn", dog: "corn"} = build(:single_key_prop, person: person) end end From 14334e659a9edc822ca41c4aedb51c7bfa1138f1 Mon Sep 17 00:00:00 2001 From: Matthew Boehlig Date: Tue, 18 Apr 2023 02:39:32 -0500 Subject: [PATCH 2/3] fix factory test --- .../test/blunt/data/factories/factory_test.exs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/apps/blunt_data/test/blunt/data/factories/factory_test.exs b/apps/blunt_data/test/blunt/data/factories/factory_test.exs index 0e5b31d..358372a 100644 --- a/apps/blunt_data/test/blunt/data/factories/factory_test.exs +++ b/apps/blunt_data/test/blunt/data/factories/factory_test.exs @@ -9,17 +9,18 @@ defmodule Blunt.Data.Factories.FactoryTest do prop :name, fn %{name: name} -> name end end - test "error indicates what prop failed evaluatation" do + test "error indicates what prop failed evaluation" do exception = assert_raise(ValueError, fn -> build(:error_env) end) - """ - factory: error_env - prop: :name + assert ValueError.message(exception) == """ - %FunctionClauseError{module: Blunt.Data.Factories.FactoryTest, function: :\"-error_env_factory/1-fun-0-\", arity: 1, kind: nil, args: nil, clauses: nil} - """ == ValueError.message(exception) + factory: error_env + prop: :name + + %FunctionClauseError{module: Blunt.Data.Factories.FactoryTest, function: :\"-error_env_factory/1-fun-0-\", arity: 1, kind: nil, args: nil, clauses: nil} + """ end end From 2cb2065007d5116b335c975422a94e2faa31d5c8 Mon Sep 17 00:00:00 2001 From: Matthew Boehlig Date: Tue, 18 Apr 2023 02:39:50 -0500 Subject: [PATCH 3/3] fix opentelemtry test --- apps/opentelemetry_blunt/test/opentelemetry_blunt_test.exs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/apps/opentelemetry_blunt/test/opentelemetry_blunt_test.exs b/apps/opentelemetry_blunt/test/opentelemetry_blunt_test.exs index b3d2209..5e1459e 100644 --- a/apps/opentelemetry_blunt/test/opentelemetry_blunt_test.exs +++ b/apps/opentelemetry_blunt/test/opentelemetry_blunt_test.exs @@ -69,15 +69,14 @@ defmodule OpentelemetryBluntTest do assert_receive( {:span, span( - name: "dispatch", + name: "blunt.dispatch", attributes: attributes, parent_span_id: :undefined, status: :undefined )} ) - :otel_attributes.map(attributes) - |> IO.inspect(label: "~/code/personal/blunt/apps/opentelemetry_blunt/test/opentelemetry_blunt_test.exs:79") + assert %{message_module: OpentelemetryBluntTest.MyCommand} = :otel_attributes.map(attributes) end end end