-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copier_test.go
55 lines (52 loc) · 1.12 KB
/
Copier_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
package copier
import (
"reflect"
"testing"
)
func TestCopier_CopyStructToMap(t *testing.T) {
type fields struct {
Source interface{}
SourceType reflect.Type
Destination interface{}
DestinationType reflect.Type
Configuration Config
}
tests := []struct {
name string
fields fields
wantErr bool
}{
// TODO: Add test cases.
{
name: "convert Stuct to Map",
fields: fields{
Source: struct {
Name string
Email string
}{
"Hari",
"",
},
Destination: make(map[string]interface{}),
Configuration: Config{
OmitEmpty: true,
},
},
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
copier := &Copier{
Source: tt.fields.Source,
SourceType: tt.fields.SourceType,
Destination: tt.fields.Destination,
DestinationType: tt.fields.DestinationType,
Configuration: tt.fields.Configuration,
}
if err := copier.CopyStructToMap(); (err != nil) != tt.wantErr {
t.Errorf("Copier.CopyStructToMap() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}