Skip to content

Commit 39e8629

Browse files
jredvilledarrenklein
authored andcommitted
Fix tests
1 parent 0a69141 commit 39e8629

File tree

1 file changed

+55
-24
lines changed

1 file changed

+55
-24
lines changed

lib/ex_aws/dynamo.ex

Lines changed: 55 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ defmodule ExAws.Dynamo do
7777
@type primary_key :: [{atom, binary}] | %{atom => binary}
7878
@type exclusive_start_key_vals :: [{atom, binary}] | %{atom => binary}
7979
@type expression_attribute_names_vals :: %{binary => binary}
80-
@type expression_attribute_values_vals :: [{atom, Dynamo.Encodable.t()}] | %{atom => Dynamo.Encodable.t()}
80+
@type expression_attribute_values_vals ::
81+
[{atom, Dynamo.Encodable.t()}] | %{atom => Dynamo.Encodable.t()}
8182
@type return_consumed_capacity_vals ::
8283
:none
8384
| :total
@@ -179,7 +180,14 @@ defmodule ExAws.Dynamo do
179180
billing_mode
180181
)
181182
when is_atom(primary_key) or is_binary(primary_key) do
182-
create_table(name, [{primary_key, :hash}], key_definitions, read_capacity, write_capacity, billing_mode)
183+
create_table(
184+
name,
185+
[{primary_key, :hash}],
186+
key_definitions,
187+
read_capacity,
188+
write_capacity,
189+
billing_mode
190+
)
183191
end
184192

185193
def create_table(
@@ -191,7 +199,16 @@ defmodule ExAws.Dynamo do
191199
billing_mode
192200
)
193201
when is_list(key_schema) do
194-
create_table(name, key_schema, key_definitions, read_capacity, write_capacity, [], [], billing_mode)
202+
create_table(
203+
name,
204+
key_schema,
205+
key_definitions,
206+
read_capacity,
207+
write_capacity,
208+
[],
209+
[],
210+
billing_mode
211+
)
195212
end
196213

197214
@doc """
@@ -305,7 +322,8 @@ defmodule ExAws.Dynamo do
305322
end
306323

307324
@doc "Update Table"
308-
@spec update_table(name :: binary, attributes :: Keyword.t() | Map.t()) :: ExAws.Operation.JSON.t()
325+
@spec update_table(name :: binary, attributes :: Keyword.t() | Map.t()) ::
326+
ExAws.Operation.JSON.t()
309327
def update_table(name, attributes) do
310328
data =
311329
attributes
@@ -324,11 +342,16 @@ defmodule ExAws.Dynamo do
324342
end
325343
end
326344

327-
@spec convert_billing_mode(attributes :: Keyword.t() | Map.t(), dynamo_billing_types) :: Keyword.t() | Map.t()
328-
defp convert_billing_mode(attributes, :provisioned), do: do_convert_billing_mode(attributes, "PROVISIONED")
329-
defp convert_billing_mode(attributes, :pay_per_request), do: do_convert_billing_mode(attributes, "PAY_PER_REQUEST")
345+
@spec convert_billing_mode(attributes :: Keyword.t() | Map.t(), dynamo_billing_types) ::
346+
Keyword.t() | Map.t()
347+
defp convert_billing_mode(attributes, :provisioned),
348+
do: do_convert_billing_mode(attributes, "PROVISIONED")
349+
350+
defp convert_billing_mode(attributes, :pay_per_request),
351+
do: do_convert_billing_mode(attributes, "PAY_PER_REQUEST")
330352

331-
@spec do_convert_billing_mode(attributes :: Keyword.t() | Map.t(), value :: String.t()) :: Keyword.t() | Map.t()
353+
@spec do_convert_billing_mode(attributes :: Keyword.t() | Map.t(), value :: String.t()) ::
354+
Keyword.t() | Map.t()
332355
defp do_convert_billing_mode(attributes, value) when is_map(attributes),
333356
do: Map.replace!(attributes, :billing_mode, value)
334357

@@ -342,7 +365,8 @@ defmodule ExAws.Dynamo do
342365
end
343366

344367
@doc "Update time to live"
345-
@spec update_time_to_live(table :: binary, ttl_attribute :: binary, enabled :: boolean) :: ExAws.Operation.JSON.t()
368+
@spec update_time_to_live(table :: binary, ttl_attribute :: binary, enabled :: boolean) ::
369+
ExAws.Operation.JSON.t()
346370
def update_time_to_live(table, ttl_attribute, enabled) do
347371
data = build_time_to_live(ttl_attribute, enabled) |> Map.merge(%{"TableName" => table})
348372

@@ -501,7 +525,8 @@ defmodule ExAws.Dynamo do
501525
| {:projection_expression, binary}
502526
]
503527
@spec batch_get_item(%{table_name => get_item}) :: ExAws.Operation.JSON.t()
504-
@spec batch_get_item(%{table_name => get_item}, opts :: batch_get_item_opts) :: ExAws.Operation.JSON.t()
528+
@spec batch_get_item(%{table_name => get_item}, opts :: batch_get_item_opts) ::
529+
ExAws.Operation.JSON.t()
505530
def batch_get_item(data, opts \\ []) do
506531
request_items =
507532
data
@@ -526,8 +551,7 @@ defmodule ExAws.Dynamo do
526551

527552
data =
528553
opts
529-
|> add_upcased_opt(opts, :return_consumed_capacity)
530-
|> camelize_keys
554+
|> build_opts()
531555
|> Map.merge(%{"RequestItems" => request_items})
532556

533557
request(:batch_get_item, data)
@@ -543,7 +567,8 @@ defmodule ExAws.Dynamo do
543567
| {:return_values, return_values_vals}
544568
]
545569
@spec put_item(table_name :: table_name, record :: map()) :: ExAws.Operation.JSON.t()
546-
@spec put_item(table_name :: table_name, record :: map(), opts :: put_item_opts) :: ExAws.Operation.JSON.t()
570+
@spec put_item(table_name :: table_name, record :: map(), opts :: put_item_opts) ::
571+
ExAws.Operation.JSON.t()
547572
def put_item(name, record, opts \\ []) do
548573
data =
549574
opts
@@ -574,7 +599,8 @@ defmodule ExAws.Dynamo do
574599
| {:return_item_collection_metrics, return_item_collection_metrics_vals}
575600
]
576601
@spec batch_write_item(%{table_name => [write_item]}) :: ExAws.Operation.JSON.t()
577-
@spec batch_write_item(%{table_name => [write_item]}, opts :: batch_write_item_opts) :: ExAws.Operation.JSON.t()
602+
@spec batch_write_item(%{table_name => [write_item]}, opts :: batch_write_item_opts) ::
603+
ExAws.Operation.JSON.t()
578604
def batch_write_item(data, opts \\ []) do
579605
request_items =
580606
data
@@ -594,9 +620,7 @@ defmodule ExAws.Dynamo do
594620

595621
data =
596622
opts
597-
|> add_upcased_opt(opts, :return_item_collection_metrics)
598-
|> add_upcased_opt(opts, :return_consumed_capacity)
599-
|> camelize_keys
623+
|> build_opts()
600624
|> Map.merge(%{"RequestItems" => request_items})
601625

602626
request(:batch_write_item, data)
@@ -665,7 +689,8 @@ defmodule ExAws.Dynamo do
665689
| {:return_item_collection_metrics, return_item_collection_metrics_vals}
666690
| {:return_values, return_values_vals}
667691
]
668-
@spec delete_item(table_name :: table_name, primary_key :: primary_key) :: ExAws.Operation.JSON.t()
692+
@spec delete_item(table_name :: table_name, primary_key :: primary_key) ::
693+
ExAws.Operation.JSON.t()
669694
@spec delete_item(
670695
table_name :: table_name,
671696
primary_key :: primary_key,
@@ -696,7 +721,8 @@ defmodule ExAws.Dynamo do
696721
{:return_consumed_capacity, return_consumed_capacity_vals}
697722
]
698723

699-
@spec transact_get_items(items :: [transact_get_item], transact_get_items_opts) :: ExAws.Operation.JSON.t()
724+
@spec transact_get_items(items :: [transact_get_item], transact_get_items_opts) ::
725+
ExAws.Operation.JSON.t()
700726
@spec transact_get_items(items :: [transact_get_item]) :: ExAws.Operation.JSON.t()
701727

702728
@doc """
@@ -713,7 +739,8 @@ defmodule ExAws.Dynamo do
713739
request(:transact_get_items, data)
714740
end
715741

716-
defp build_transaction_item({method, {table, item}}), do: build_transaction_item({method, {table, item, []}})
742+
defp build_transaction_item({method, {table, item}}),
743+
do: build_transaction_item({method, {table, item, []}})
717744

718745
defp build_transaction_item({method, {table, item, opts}}) do
719746
build_transaction_item(method, table, item, opts)
@@ -742,19 +769,22 @@ defmodule ExAws.Dynamo do
742769
{:condition_expression, binary}
743770
| {:expression_attribute_names, expression_attribute_names_vals}
744771
| {:expression_attribute_values, expression_attribute_values_vals}
745-
| {:return_values_on_condition_check_failure, return_values_on_condition_check_failure_vals}
772+
| {:return_values_on_condition_check_failure,
773+
return_values_on_condition_check_failure_vals}
746774
]
747775

748776
@type transact_update_item_opts :: [
749777
{:condition_expression, binary}
750778
| {:expression_attribute_names, expression_attribute_names_vals}
751779
| {:expression_attribute_values, expression_attribute_values_vals}
752-
| {:return_values_on_condition_check_failure, return_values_on_condition_check_failure_vals}
780+
| {:return_values_on_condition_check_failure,
781+
return_values_on_condition_check_failure_vals}
753782
| {:update_expression, binary}
754783
]
755784

756785
@type transact_write_item ::
757-
{:condition_check, {table_name :: binary, key :: primary_key, transact_standard_item_opts}}
786+
{:condition_check,
787+
{table_name :: binary, key :: primary_key, transact_standard_item_opts}}
758788
| {:delete, {table_name :: binary, key :: primary_key, transact_standard_item_opts}}
759789
| {:put, {table_name :: binary, item :: map(), transact_standard_item_opts}}
760790
| {:update, {table_name :: binary, key :: primary_key, transact_update_item_opts}}
@@ -768,7 +798,8 @@ defmodule ExAws.Dynamo do
768798
@doc """
769799
A synchronous write operation that groups up to 25 action requests
770800
"""
771-
@spec transact_write_items(items :: [transact_write_item], transact_write_items_opts) :: ExAws.Operation.JSON.t()
801+
@spec transact_write_items(items :: [transact_write_item], transact_write_items_opts) ::
802+
ExAws.Operation.JSON.t()
772803
@spec transact_write_items(items :: [transact_write_item]) :: ExAws.Operation.JSON.t()
773804
def transact_write_items(items, opts \\ []) do
774805
data =

0 commit comments

Comments
 (0)