-
Notifications
You must be signed in to change notification settings - Fork 23
/
index_test.go
57 lines (43 loc) · 1.5 KB
/
index_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
package dynamodb
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestNewLSI(t *testing.T) {
assert := assert.New(t)
keys := NewKeySchema(NewHashKeyElement("foo"))
lsi := NewLSI("name", keys)
assert.Equal("name", *lsi.IndexName)
assert.Equal(ProjectionTypeAll, *lsi.Projection.ProjectionType)
k := lsi.KeySchema
assert.Len(k, 1)
assert.Equal("foo", *k[0].AttributeName)
lsi2 := NewLSI("name", keys, ProjectionTypeKeysOnly)
assert.Equal("name", *lsi2.IndexName)
assert.Equal(ProjectionTypeKeysOnly, *lsi2.Projection.ProjectionType)
k = lsi2.KeySchema
assert.Len(k, 1)
assert.Equal("foo", *k[0].AttributeName)
}
func TestNewGSI(t *testing.T) {
assert := assert.New(t)
keys := NewKeySchema(NewHashKeyElement("foo"))
gsi := NewGSI("name", keys, newProvisionedThroughput(5, 8))
assert.Equal("name", *gsi.IndexName)
assert.Equal(ProjectionTypeAll, *gsi.Projection.ProjectionType)
k := gsi.KeySchema
assert.Len(k, 1)
assert.Equal("foo", *k[0].AttributeName)
tp := gsi.ProvisionedThroughput
assert.EqualValues(5, *tp.ReadCapacityUnits)
assert.EqualValues(8, *tp.WriteCapacityUnits)
gsi2 := NewGSI("name", keys, newProvisionedThroughput(5, 8), ProjectionTypeKeysOnly)
assert.Equal("name", *gsi2.IndexName)
assert.Equal(ProjectionTypeKeysOnly, *gsi2.Projection.ProjectionType)
k = gsi2.KeySchema
assert.Len(k, 1)
assert.Equal("foo", *k[0].AttributeName)
tp = gsi2.ProvisionedThroughput
assert.EqualValues(5, *tp.ReadCapacityUnits)
assert.EqualValues(8, *tp.WriteCapacityUnits)
}