forked from groovili/go-dynamock-v2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvalidate.go
55 lines (40 loc) · 921 Bytes
/
validate.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
package dynamock
import (
"reflect"
"github.com/aws/aws-sdk-go-v2/aws"
)
func validateInput(v aws.Validator, r *aws.Request) {
if err := v.Validate(); err != nil {
r.Error = ErrInvalidInput
}
}
func validateKey(wantKey interface{}, gotKey interface{}, r *aws.Request) {
if wantKey == nil {
r.Error = ErrNoKey
return
}
if !reflect.DeepEqual(wantKey, gotKey) {
r.Error = ErrKeyExpectationMismatch
return
}
}
func validateItem(wantItem interface{}, gotItem interface{}, r *aws.Request) {
if wantItem == nil {
r.Error = ErrNoItem
return
}
if !reflect.DeepEqual(wantItem, gotItem) {
r.Error = ErrItemExpectationMismatch
return
}
}
func validateTable(wantTable *string, gotTable *string, r *aws.Request) {
if gotTable == nil {
r.Error = ErrNoTable
return
}
if !(aws.StringValue(gotTable) == aws.StringValue(wantTable)) {
r.Error = ErrTableExpectationMismatch
return
}
}