-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhelper_test.go
71 lines (56 loc) · 1.13 KB
/
helper_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
69
70
71
package backends
import (
"fmt"
"testing"
)
func TestInterfaceToMap(t *testing.T) {
testMap := map[string]interface{}{
"key": "val",
}
result, err := InterfaceToMap(&testMap)
if err != nil {
t.Errorf(err.Error())
}
if result == nil {
t.Errorf("Nil map")
}
}
func TestMapToInterface(t *testing.T) {
testMap := map[string]interface{}{
"key": "val",
}
var result interface{}
err := MapToInterface(testMap, &result)
if err != nil {
t.Errorf(err.Error())
}
if result == nil {
t.Errorf("Nil map")
}
}
func TestStringToObjectID(t *testing.T) {
testMap := map[string]interface{}{
"id": "5975c461f9f8eb02aae053f3",
}
err := stringToObjectID(testMap)
if err != nil {
t.Errorf(err.Error())
}
if _, ok := testMap["_id"]; !ok {
t.Errorf("ID not transformed")
}
}
func TestIsConditionalCheckErr(t *testing.T) {
ok := IsConditionalCheckErr(fmt.Errorf("Some error"))
if ok {
t.Errorf("Error is not ConditionalCheckFailedException")
}
}
func TestContains(t *testing.T) {
val := "value"
arr := []*string{&val}
ok := contains(arr, val)
if !ok {
t.Errorf("Expected array to contain the item 'value'")
}
}