-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdocument_mutation_test.go
More file actions
28 lines (25 loc) · 947 Bytes
/
document_mutation_test.go
File metadata and controls
28 lines (25 loc) · 947 Bytes
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
package private_maprdb_go_client
import (
"fmt"
"github.com/stretchr/testify/assert"
"testing"
)
func TestSetMultipleTime(t *testing.T) {
docMutation, err := MakeDocumentMutation(Set("a", 12), Set("b", 55), Set("a", 33))
if err != nil {
t.Errorf(err.Error())
}
assert.Equal(t, map[string]interface{}{"$set": []interface{}{
map[string]interface{}{"a": 33}, map[string]interface{}{"b": 55},
}}, docMutation.mutationMap)
}
func TestMultipleMutationOperations(t *testing.T) {
docMutation, err := MakeDocumentMutation(Set("a", 12), Set("b", 55), SetOrReplace("s.o.r", "replace"),
IncrementInt("inc1", 2), IncrementIntByOne("inc2"), IncrementFloat64("inc3", 25), DecrementFloat64("dec1", 5))
if err != nil {
t.Errorf(err.Error())
}
assert.Equal(t,
"map[$set:[map[a:12] map[b:55]] $put:map[s.o.r:replace] $increment:[map[inc1:2] map[inc2:1] map[inc3:25]] $decrement:map[dec1:5]]",
fmt.Sprintf("%v", docMutation.mutationMap))
}