forked from dugancathal/dynago
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient_test.go
38 lines (32 loc) · 1.2 KB
/
client_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
package dynago
import (
"github.com/stretchr/testify/assert"
"testing"
"github.com/bemobi/dynago/internal/aws"
)
func setUp(t *testing.T) (*assert.Assertions, *Client, *MockExecutor) {
t.Parallel()
executor := &MockExecutor{}
return assert.New(t), NewClient(executor), executor
}
func TestQueryParams(t *testing.T) {
assert, client, _ := setUp(t)
q := client.Query("Foo").Param(":start", 9)
assert.Equal(1, len(q.req.ExpressionAttributeValues))
q2 := q.Params(Param{":end", 4}, Param{":other", "hello"}, Param{"#name", "Name"})
assert.Equal(3, len(q2.req.ExpressionAttributeValues))
assert.Equal(1, len(q2.req.ExpressionAttributeNames))
assert.Equal("Name", q2.req.ExpressionAttributeNames["#name"])
}
func TestNewAwsClient(t *testing.T) {
assert := assert.New(t)
client := NewAwsClient("us-east-1", "abc", "def")
assert.IsType(&AwsExecutor{}, client.executor)
executor := client.executor.(*AwsExecutor)
requester := executor.Requester.(*aws.RequestMaker)
assert.Equal("https://dynamodb.us-east-1.amazonaws.com:443/", requester.Endpoint)
signer := requester.Signer.(*aws.AwsSigner)
assert.Equal("us-east-1", signer.Region)
assert.Equal("abc", signer.AccessKey)
assert.Equal("def", signer.SecretKey)
}