-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathtopic_test.go
46 lines (36 loc) · 949 Bytes
/
topic_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package sns
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestNewTopic(t *testing.T) {
assert := assert.New(t)
svc := getTestClient(t)
tp := NewTopic(svc, "arn", "name")
assert.NotNil(tp)
assert.Equal("arn", tp.arn)
assert.Equal("name", tp.name)
assert.Equal(svc, tp.svc)
}
func TestSubscribe(t *testing.T) {
assert := assert.New(t)
svc := getTestClient(t)
topicName := "fooTopic"
topic, _ := svc.CreateTopic(topicName)
e := svc.newApplicationEndpoint("arn")
res, err := topic.Subscribe(e.arn, e.protocol)
assert.NoError(err)
assert.Contains(res, "arn:aws:sns:")
assert.Contains(res, topicName)
}
func TestTopicPublish(t *testing.T) {
assert := assert.New(t)
svc := getTestClient(t)
if svc.client.Endpoint == defaultEndpoint {
t.Skip("fakesns does not implement Publish() yet.")
}
topicName := "fooTopic"
topic, _ := svc.CreateTopic(topicName)
err := topic.Publish("foo")
assert.NoError(err)
}