Skip to content

Commit be699f4

Browse files
lll-lll-lll-lllAlexVulaj
authored andcommitted
fix delete pointer slice test
1 parent 50924ff commit be699f4

File tree

1 file changed

+6
-25
lines changed

1 file changed

+6
-25
lines changed

decoder_test.go

+6-25
Original file line numberDiff line numberDiff line change
@@ -2217,42 +2217,27 @@ func TestRequiredFieldsCannotHaveDefaults(t *testing.T) {
22172217

22182218
func TestInvalidDefaultElementInSliceRaiseError(t *testing.T) {
22192219
type D struct {
2220-
A []int `schema:"a,default:0|notInt"`
2221-
B []bool `schema:"b,default:true|notInt"`
2222-
C []*float32 `schema:"c,default:1.1|notInt"`
2220+
A []int `schema:"a,default:0|notInt"`
2221+
B []bool `schema:"b,default:true|notInt"`
22232222
// //uint types
22242223
D []uint `schema:"d,default:1|notInt"`
22252224
E []uint8 `schema:"e,default:2|notInt"`
22262225
F []uint16 `schema:"f,default:3|notInt"`
22272226
G []uint32 `schema:"g,default:4|notInt"`
22282227
H []uint64 `schema:"h,default:5|notInt"`
2229-
// // uint types pointers
2230-
I []*uint `schema:"i,default:6|notInt"`
2231-
J []*uint8 `schema:"j,default:7|notInt"`
2232-
K []*uint16 `schema:"k,default:12|notInt"`
2233-
L []*uint32 `schema:"l,default:129|notInt"`
2234-
M []*uint64 `schema:"m,default:11111|notInt"`
22352228
// // int types
22362229
N []int `schema:"n,default:11|notInt"`
22372230
O []int8 `schema:"o,default:12|notInt"`
22382231
P []int16 `schema:"p,default:13|notInt"`
22392232
Q []int32 `schema:"q,default:14|notInt"`
22402233
R []int64 `schema:"r,default:15|notInt"`
2241-
// // int types pointers
2242-
S []*int `schema:"s,default:1000|notInt"`
2243-
T []*int8 `schema:"t,default:1000|notInt"`
2244-
U []*int16 `schema:"u,default:1000|notInt"`
2245-
V []*int32 `schema:"v,default:22222|notInt"`
2246-
W []*int64 `schema:"w,default:11111|notInt"`
22472234
// // float
2248-
X []float32 `schema:"c,default:2.2|notInt"`
2249-
Y []float64 `schema:"c,default:3.3|notInt"`
2250-
Z []*float64 `schema:"c,default:4.4|notInt"`
2235+
X []float32 `schema:"c,default:2.2|notInt"`
2236+
Y []float64 `schema:"c,default:3.3|notInt"`
22512237
}
22522238
d := D{}
22532239

22542240
data := map[string][]string{}
2255-
pErrMsg := "default option is supported only on: bool, float variants, string, unit variants types or their corresponding pointers or slices"
22562241
eng := "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
22572242

22582243
decoder := NewDecoder()
@@ -2264,17 +2249,13 @@ func TestInvalidDefaultElementInSliceRaiseError(t *testing.T) {
22642249
}
22652250

22662251
e, ok := err.(MultiError)
2267-
if !ok || len(e) != 26 {
2268-
t.Errorf("Expected 26 errors, got %#v", err)
2252+
if !ok || len(e) != 14 {
2253+
t.Errorf("Expected 14 errors, got %#v", err)
22692254
}
22702255
for _, v := range eng {
22712256
fieldKey := "default-" + string(v)
22722257
errMsg := fmt.Sprintf("failed setting default: notInt is not compatible with field %s type", string(v))
22732258
if ferr, ok := e[fieldKey]; ok {
2274-
// check pointer type field
2275-
if ferr.Error() == pErrMsg {
2276-
continue
2277-
}
22782259
if strings.Compare(ferr.Error(), errMsg) != 0 {
22792260
t.Errorf("%s: expected %s, got %#v", fieldKey, ferr.Error(), errMsg)
22802261
}

0 commit comments

Comments
 (0)