-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwith_record_changes_test.go
109 lines (105 loc) · 2.18 KB
/
with_record_changes_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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
package record
import (
"context"
"github.com/dal-go/dalgo/dal"
"github.com/stretchr/testify/assert"
"testing"
)
func TestWithRecordChanges_ApplyChanges(t *testing.T) {
type fields struct {
recordsToInsert []dal.Record
RecordsToUpdate []*Updates
RecordsToDelete []*dal.Key
}
type args struct {
ctx context.Context
tx dal.ReadwriteTransaction
excludeKeys []*dal.Key
}
tests := []struct {
name string
fields fields
args args
assertErr assert.ErrorAssertionFunc
}{
{
name: "nil",
fields: fields{
recordsToInsert: nil,
RecordsToUpdate: nil,
RecordsToDelete: nil,
},
assertErr: assert.NoError,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
v := &WithRecordChanges{
recordsToInsert: tt.fields.recordsToInsert,
RecordsToUpdate: tt.fields.RecordsToUpdate,
RecordsToDelete: tt.fields.RecordsToDelete,
}
err := v.ApplyChanges(tt.args.ctx, tt.args.tx, tt.args.excludeKeys...)
tt.assertErr(t, err)
})
}
}
func TestWithRecordChanges_QueueForInsert(t *testing.T) {
type fields struct {
recordsToInsert []dal.Record
}
type args struct {
records []dal.Record
}
tests := []struct {
name string
fields fields
args args
}{
{
name: "nil",
fields: fields{
recordsToInsert: nil,
},
args: args{
records: nil,
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
v := &WithRecordChanges{
recordsToInsert: tt.fields.recordsToInsert,
}
v.QueueForInsert(tt.args.records...)
})
}
}
func TestWithRecordChanges_RecordsToInsert(t *testing.T) {
type fields struct {
recordsToInsert []dal.Record
RecordsToUpdate []*Updates
RecordsToDelete []*dal.Key
}
tests := []struct {
name string
fields fields
}{
{
name: "nil",
fields: fields{
recordsToInsert: nil,
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
v := &WithRecordChanges{
recordsToInsert: tt.fields.recordsToInsert,
RecordsToUpdate: tt.fields.RecordsToUpdate,
RecordsToDelete: tt.fields.RecordsToDelete,
}
assert.Equalf(t, tt.fields.recordsToInsert, v.RecordsToInsert(), "RecordsToInsert()")
})
}
}