-
Notifications
You must be signed in to change notification settings - Fork 0
/
data_test.go
238 lines (187 loc) · 3.97 KB
/
data_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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
package autowire
import (
"context"
"errors"
)
var (
errTest1 = errors.New("errTest1")
)
//
// SERVICES
//
type ServiceBase interface {
InitArgs() []any
}
type Service1 interface {
ServiceBase
}
type Service2 interface {
ServiceBase
}
type Service3 interface {
ServiceBase
}
type Service4 interface {
ServiceBase
}
type Service5 interface {
ServiceBase
}
type serviceBase struct {
initArgs []any
}
func (s serviceBase) InitArgs() []any {
return s.initArgs
}
type service1 struct {
serviceBase
}
type service2 struct {
serviceBase
}
type service3 struct {
serviceBase
}
type service4 struct {
serviceBase
}
type service5 struct {
serviceBase
}
// CREATE FUNCTIONS - Service 1
func NewSrv1_OK() Service1 {
return &service1{}
}
func NewSrv1_OK_With_Need_Srv2_Srv3(s2 Service2, s3 Service3) Service1 {
return &service1{serviceBase{initArgs: []any{s2, s3}}}
}
func NewSrv1_OK_With_Need_Srv2_Srv3_Struct1(s2 Service2, s3 Service3, st1 *Struct1_OK) Service1 {
return &service1{serviceBase{initArgs: []any{s2, s3, st1}}}
}
func NewSrv1_OK_With_Need_Srv2_Srv3_IntSlice(s2 Service2, s3 Service3, ints []int) Service1 {
return &service1{serviceBase{initArgs: []any{s2, s3, ints}}}
}
func NewSrv1_OK_With_Nil_Err() (Service1, error) {
return &service1{}, nil
}
func NewSrv1_OK_With_Need_Ctx(ctx context.Context) Service1 {
return &service1{serviceBase{initArgs: []any{ctx}}}
}
func NewSrv1_Fail_With_Err() (Service1, error) {
return nil, errTest1
}
func NewSrv1_Fail_With_0_Ret_Value() {
}
func NewSrv1_Fail_With_3_Ret_Values() (Service1, int, error) {
return nil, 123, errTest1
}
func NewSrv1_Fail_With_Non_Err_At_Last() (Service1, int) {
return service1{}, 123
}
func NewSrv1_Fail_With_Dup_Arg_Type(i1 int, s2 Service2, i2 int) (Service1, error) {
return service1{}, nil
}
func NewSrv1_Fail_With_Variadic(s2 Service2, ii ...int) Service1 {
return service1{}
}
func NewSrv1_Fail_Need_Srv1(s1 Service1) (Service1, error) {
return service1{}, nil
}
// CREATE FUNCTIONS - Service 2
func NewSrv2_OK() Service2 {
return &service2{}
}
func NewSrv2_OK_With_Need_Srv4_Srv5(s4 Service4, s5 Service5) (Service2, error) {
return &service2{serviceBase{initArgs: []any{s4, s5}}}, nil
}
// CREATE FUNCTIONS - Service 3
func NewSrv3_OK() Service3 {
return &service3{}
}
// CREATE FUNCTIONS - Service 4
func NewSrv4_OK() Service4 {
return &service4{}
}
func NewSrv4_OK_With_Need_Srv1(s1 Service1) (Service4, error) {
return &service4{serviceBase{initArgs: []any{s1}}}, nil
}
// CREATE FUNCTIONS - Service 5
func NewSrv5_OK() Service5 {
return &service5{}
}
//
// STRUCTS
//
type Struct1_OK struct {
Int int
Str string
Slice []int
Map map[string]int64
Map2 map[string]string
}
type Struct2_Dup_Field_Type struct {
Struct1_OK
AnotherSlice []int
}
type Struct3_Empty struct {
}
type Struct4_OK_Dup_Field_Type_Unexported struct {
Struct1_OK
unexportedSlice []int
}
type Struct5_OK struct {
IntP *int
}
type Struct6_OK_Nested_Anonymous struct {
Int int
Nested1 struct {
Int16 int16
Str string
Nested2 struct {
Slice []int
Map map[int]int
}
}
}
type Struct7_OK_Nested struct {
Int int
Nested1 Nested1
}
type Nested1 struct {
Int16 int16
Str string
Nested2 *Nested2
}
type Nested2 struct {
Slice []int
Map map[int]int
}
var (
struct1_OK = Struct1_OK{
Int: 123,
Str: "abc",
Slice: []int{1, 2, 3},
Map: map[string]int64{"abc": 123},
Map2: map[string]string{"abc": "123"},
}
struct2_Dup_Field_Type = Struct2_Dup_Field_Type{}
struct3_Empty = Struct3_Empty{}
struct4_OK_Dup_Field_Type_Unexported = Struct4_OK_Dup_Field_Type_Unexported{
Struct1_OK: struct1_OK,
}
struct5_OK = Struct5_OK{}
struct6_OK_Nested_Anonymous = Struct6_OK_Nested_Anonymous{
Int: 123,
}
struct7_OK_Nested = Struct7_OK_Nested{
Int: 123,
Nested1: Nested1{
Int16: 16,
Str: "abc",
Nested2: &Nested2{
Slice: []int{1, 2, 3},
Map: map[int]int{1: 1, 2: 2, 3: 3},
},
},
}
)