Skip to content

Commit 12c5b86

Browse files
milkcocoabenwilson512
authored andcommitted
Fix could not find operation error. (#177)
1 parent 8f401e3 commit 12c5b86

File tree

2 files changed

+49
-6
lines changed

2 files changed

+49
-6
lines changed

lib/ex_aws/sns.ex

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,27 +78,27 @@ defmodule ExAws.SNS do
7878
|> Map.new
7979
|> camelize_keys
8080

81-
request(:list_topics, opts)
81+
request("ListTopics", opts)
8282
end
8383

8484
@doc "Create topic"
8585
@spec create_topic(topic_name :: topic_name) :: ExAws.Operation.Query.t
8686
def create_topic(topic_name) do
87-
request(:create_topic, %{"Name" => topic_name})
87+
request("CreateTopic", %{"Name" => topic_name})
8888
end
8989

9090
@doc "Get topic attributes"
9191
@spec get_topic_attributes(topic_arn :: topic_arn) :: ExAws.Operation.Query.t
9292
def get_topic_attributes(topic_arn) do
93-
request(:get_topic_attributes, %{"TopicArn" => topic_arn})
93+
request("GetTopicAttributes", %{"TopicArn" => topic_arn})
9494
end
9595

9696
@doc "Set topic attributes"
9797
@spec set_topic_attributes(attribute_name :: topic_attribute_name,
9898
attribute_value :: binary,
9999
topic_arn :: topic_arn) :: ExAws.Operation.Query.t
100100
def set_topic_attributes(attribute_name, attribute_value, topic_arn) do
101-
request(:set_topic_attributes, %{
101+
request("SetTopicAttributes", %{
102102
"AttributeName" => attribute_name |> camelize_key,
103103
"AttributeValue" => attribute_value,
104104
"TopicArn" => topic_arn
@@ -108,7 +108,7 @@ defmodule ExAws.SNS do
108108
@doc "Delete topic"
109109
@spec delete_topic(topic_arn :: topic_arn) :: ExAws.Operation.Query.t
110110
def delete_topic(topic_arn) do
111-
request(:delete_topic, %{"TopicArn" => topic_arn})
111+
request("DeleteTopic", %{"TopicArn" => topic_arn})
112112
end
113113

114114
@type message_attribute :: %{
@@ -146,7 +146,7 @@ defmodule ExAws.SNS do
146146
|> Map.put("Message", message)
147147
|> Map.merge(message_attrs)
148148

149-
request(:publish, params)
149+
request("Publish", params)
150150
end
151151

152152
defp build_message_attributes(attrs) do

test/lib/ex_aws/sns_test.exs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
defmodule ExAws.SNSTest do
2+
use ExUnit.Case, async: true
3+
alias ExAws.SNS
4+
5+
test "#list_topics" do
6+
expected = %{"Action" => "ListTopics"}
7+
assert expected == SNS.list_topics().params
8+
end
9+
10+
test "#create_topic" do
11+
expected = %{"Action" => "CreateTopic", "Name" => "test_topic"}
12+
assert expected == SNS.create_topic("test_topic").params
13+
end
14+
15+
test "#get_topic_attributes" do
16+
expected = %{"Action" => "GetTopicAttributes", "TopicArn" => "arn:aws:sns:us-east-1:982071696186:test-topic"}
17+
assert expected == SNS.get_topic_attributes("arn:aws:sns:us-east-1:982071696186:test-topic").params
18+
end
19+
20+
test "#set_topic_attributes" do
21+
expected = %{
22+
"Action" => "SetTopicAttributes",
23+
"AttributeName" => "DeliverPolicy",
24+
"AttributeValue" => "{\"http\":{\"defaultHealthyRetryPolicy\":{\"numRetries\":5}}}",
25+
"TopicArn" => "arn:aws:sns:us-east-1:982071696186:test-topic"
26+
}
27+
assert expected == SNS.set_topic_attributes(:deliver_policy, "{\"http\":{\"defaultHealthyRetryPolicy\":{\"numRetries\":5}}}", "arn:aws:sns:us-east-1:982071696186:test-topic").params
28+
end
29+
30+
test "#delete_topic" do
31+
expected = %{"Action" => "DeleteTopic", "TopicArn" => "arn:aws:sns:us-east-1:982071696186:test-topic"}
32+
assert expected == SNS.delete_topic("arn:aws:sns:us-east-1:982071696186:test-topic").params
33+
end
34+
35+
test "#publish" do
36+
expected = %{
37+
"Action" => "Publish",
38+
"Message" => "{\"message\": \"MyMessage\"}",
39+
"TopicArn" => "arn:aws:sns:us-east-1:982071696186:test-topic"
40+
}
41+
assert expected == SNS.publish("{\"message\": \"MyMessage\"}", [topic_arn: "arn:aws:sns:us-east-1:982071696186:test-topic"]).params
42+
end
43+
end

0 commit comments

Comments
 (0)