Skip to content

Commit

Permalink
Merge branch 'small_fixes'
Browse files Browse the repository at this point in the history
Merging local branch with small fixes and additional test to master.
  • Loading branch information
darrenklein committed Aug 12, 2019
2 parents bf27832 + 5911818 commit ebc04b7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions lib/ex_aws/dynamo.ex
Original file line number Diff line number Diff line change
Expand Up @@ -309,21 +309,21 @@ defmodule ExAws.Dynamo do
end

@spec maybe_convert_billing_mode(attributes :: Keyword.t() | Map.t()) :: Keyword.t() | Map.t()
def maybe_convert_billing_mode(attributes) do
defp maybe_convert_billing_mode(attributes) do
case attributes[:billing_mode] do
nil -> attributes
_ -> convert_billing_mode(attributes, attributes[:billing_mode])
end
end

@spec convert_billing_mode(attributes :: Keyword.t() | Map.t(), dynamo_billing_types) :: Keyword.t() | Map.t()
defp convert_billing_mode(attributes, :provisioned), do: do_convert(attributes, "PROVISIONED")
defp convert_billing_mode(attributes, :pay_per_request), do: do_convert(attributes, "PAY_PER_REQUEST")
defp convert_billing_mode(attributes, :provisioned), do: do_convert_billing_mode(attributes, "PROVISIONED")
defp convert_billing_mode(attributes, :pay_per_request), do: do_convert_billing_mode(attributes, "PAY_PER_REQUEST")

@spec do_convert(attributes :: Keyword.t() | Map.t(), value :: String.t()) :: Keyword.t() | Map.t()
defp do_convert(attributes, value) when is_map(attributes),
@spec do_convert_billing_mode(attributes :: Keyword.t() | Map.t(), value :: String.t()) :: Keyword.t() | Map.t()
defp do_convert_billing_mode(attributes, value) when is_map(attributes),
do: Map.replace!(attributes, :billing_mode, value)
defp do_convert(attributes, value),
defp do_convert_billing_mode(attributes, value) when is_list(attributes),
do: Keyword.replace!(attributes, :billing_mode, value)

@doc "Delete Table"
Expand Down
8 changes: 4 additions & 4 deletions test/lib/dynamo_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@ defmodule ExAws.DynamoTest do

assert Dynamo.update_table(
"TestUsers",
[provisioned_throughput:
[read_capacity_units: 1,
write_capacity_units: 1],
%{provisioned_throughput:
%{read_capacity_units: 1,
write_capacity_units: 1},
billing_mode: :provisioned
]).data == expected
}).data == expected

expected = %{
"ProvisionedThroughput" => %{
Expand Down

0 comments on commit ebc04b7

Please sign in to comment.