-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathparser_test.go
118 lines (113 loc) · 2.69 KB
/
parser_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
110
111
112
113
114
115
116
117
118
// Package simpleRequest -----------------------------
// @file : parser_test.go
// @author : JJXu
// @contact : [email protected]
// @time : 2024/1/11 18:35
// -------------------------------------------
package simpleRequest
import (
"io"
"reflect"
"testing"
)
func TestFormDataParser_Unmarshal(t *testing.T) {
type fields struct {
ContentType string
}
type args struct {
bodyType EntryMark
BodyEntry map[string]any
}
tests := []struct {
name string
fields fields
args args
wantBody io.Reader
}{
{
name: "StringEntryType",
fields: fields{},
args: args{
bodyType: StringEntryType,
BodyEntry: map[string]any{StringEntryType.string(): "test"},
},
wantBody: nil,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
f := &FormDataParser{
ContentType: tt.fields.ContentType,
}
if gotBody := f.Unmarshal(tt.args.bodyType, tt.args.BodyEntry); !reflect.DeepEqual(gotBody, tt.wantBody) {
t.Errorf("Unmarshal() = %v, want %v", gotBody, tt.wantBody)
}
})
}
}
func TestJsonParser_Unmarshal(t *testing.T) {
type args struct {
bodyType EntryMark
BodyEntry map[string]any
}
tests := []struct {
name string
args args
want io.Reader
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
js := JsonParser{}
if got := js.Unmarshal(tt.args.bodyType, tt.args.BodyEntry); !reflect.DeepEqual(got, tt.want) {
t.Errorf("Unmarshal() = %v, want %v", got, tt.want)
}
})
}
}
func TestXmlParser_Unmarshal(t *testing.T) {
type args struct {
bodyType EntryMark
BodyEntry map[string]any
}
tests := []struct {
name string
args args
wantBody io.Reader
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
f := XmlParser{}
if gotBody := f.Unmarshal(tt.args.bodyType, tt.args.BodyEntry); !reflect.DeepEqual(gotBody, tt.wantBody) {
t.Errorf("Unmarshal() = %v, want %v", gotBody, tt.wantBody)
}
})
}
}
func Test_multipartCommonParse(t *testing.T) {
type args struct {
BodyEntry map[string]any
}
tests := []struct {
name string
args args
wantReader io.Reader
wantContentType string
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
gotReader, gotContentType := multipartCommonParse(tt.args.BodyEntry)
if !reflect.DeepEqual(gotReader, tt.wantReader) {
t.Errorf("multipartCommonParse() gotReader = %v, want %v", gotReader, tt.wantReader)
}
if gotContentType != tt.wantContentType {
t.Errorf("multipartCommonParse() gotContentType = %v, want %v", gotContentType, tt.wantContentType)
}
})
}
}