forked from elliotchance/mocksqs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_test.go
68 lines (56 loc) · 1.74 KB
/
create_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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package mocksqs_test
import (
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/sqs"
"github.com/elliotchance/mocksqs"
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
)
func TestSQS_CreateQueue(t *testing.T) {
t.Run("MissingQueueURL", func(t *testing.T) {
client := getSQSClient()
defer client.cleanup()
t.Parallel()
_, err := client.client.CreateQueue(&sqs.CreateQueueInput{})
assert.EqualError(t, err, "InvalidParameter: 1 validation error(s) found.\n- missing required field, CreateQueueInput.QueueName.\n")
})
t.Run("QueueAlreadyExists", func(t *testing.T) {
client := getSQSClientWithQueue()
defer client.cleanup()
t.Parallel()
result, err := client.client.CreateQueue(&sqs.CreateQueueInput{
QueueName: aws.String(client.queueName),
})
require.NoError(t, err)
assert.Equal(t, client.queueURL, *result.QueueUrl)
})
t.Run("Success", func(t *testing.T) {
client := getSQSClient()
defer client.cleanup()
t.Parallel()
queueName := uuid.New().String()
result, err := client.client.CreateQueue(&sqs.CreateQueueInput{
QueueName: &queueName,
})
require.NoError(t, err)
defer func() {
_, err := client.client.DeleteQueue(&sqs.DeleteQueueInput{
QueueUrl: result.QueueUrl,
})
assert.NoError(t, err)
}()
assert.Contains(t, *result.QueueUrl, "/"+queueName)
})
}
func TestSQS_CreateQueueWithContext(t *testing.T) {
assert.PanicsWithValue(t, "CreateQueueWithContext is not implemented", func() {
mocksqs.New().CreateQueueWithContext(nil, nil)
})
}
func TestSQS_CreateQueueRequest(t *testing.T) {
assert.PanicsWithValue(t, "CreateQueueRequest is not implemented", func() {
mocksqs.New().CreateQueueRequest(nil)
})
}