Skip to content

Commit bc3f765

Browse files
committed
fix: error messages now always start with a lowercase letter
Signed-off-by: Maxime Soulé <[email protected]>
1 parent 0e1b3b4 commit bc3f765

24 files changed

+192
-191
lines changed

internal/ctxerr/error_test.go

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ func TestError(t *testing.T) {
2424
Context: ctxerr.Context{
2525
Path: ctxerr.NewPath("DATA").AddArrayIndex(12).AddField("Field"),
2626
},
27-
Message: "Error message",
27+
Message: "error message",
2828
Got: 1,
2929
Expected: 2,
3030
}
3131
test.EqualStr(t, err.Error(),
32-
`DATA[12].Field: Error message
32+
`DATA[12].Field: error message
3333
got: 1
3434
expected: 2`)
3535
test.EqualStr(t, err.GotString(), "1")
@@ -58,7 +58,7 @@ func TestError(t *testing.T) {
5858
Context: ctxerr.Context{
5959
Path: ctxerr.NewPath("DATA").AddArrayIndex(12).AddField("Field"),
6060
},
61-
Message: "Error message",
61+
Message: "error message",
6262
Got: 1,
6363
Expected: 2,
6464
Location: location.Location{
@@ -68,7 +68,7 @@ func TestError(t *testing.T) {
6868
},
6969
}
7070
test.EqualStr(t, err.Error(),
71-
`DATA[12].Field: Error message
71+
`DATA[12].Field: error message
7272
got: 1
7373
expected: 2
7474
[under operator Operator at file.go:23]`)
@@ -77,7 +77,7 @@ func TestError(t *testing.T) {
7777
Context: ctxerr.Context{
7878
Path: ctxerr.NewPath("DATA").AddArrayIndex(12).AddField("Field"),
7979
},
80-
Message: "Error message",
80+
Message: "error message",
8181
Summary: ctxerr.NewSummary("666"),
8282
Location: location.Location{
8383
File: "file.go",
@@ -88,7 +88,7 @@ func TestError(t *testing.T) {
8888
Context: ctxerr.Context{
8989
Path: ctxerr.NewPath("DATA").AddArrayIndex(12).AddField("Field").AddCustomLevel("<All#1/2>"),
9090
},
91-
Message: "Origin error message",
91+
Message: "origin error message",
9292
Summary: ctxerr.NewSummary("42"),
9393
Location: location.Location{
9494
File: "file2.go",
@@ -98,10 +98,10 @@ func TestError(t *testing.T) {
9898
},
9999
}
100100
test.EqualStr(t, err.Error(),
101-
`DATA[12].Field: Error message
101+
`DATA[12].Field: error message
102102
666
103103
Originates from following error:
104-
DATA[12].Field<All#1/2>: Origin error message
104+
DATA[12].Field<All#1/2>: origin error message
105105
42
106106
[under operator SubOperator at file2.go:236]
107107
[under operator Operator at file.go:23]`)
@@ -113,7 +113,7 @@ Originates from following error:
113113
Context: ctxerr.Context{
114114
Path: ctxerr.NewPath("DATA").AddArrayIndex(12).AddField("Field"),
115115
},
116-
Message: "Error message",
116+
Message: "error message",
117117
Summary: ctxerr.NewSummary("666"),
118118
Location: location.Location{
119119
File: "file.go",
@@ -124,7 +124,7 @@ Originates from following error:
124124
Context: ctxerr.Context{
125125
Path: ctxerr.NewPath("DATA").AddArrayIndex(12).AddField("Field").AddCustomLevel("<All#1/2>"),
126126
},
127-
Message: "Origin error message",
127+
Message: "origin error message",
128128
Summary: ctxerr.NewSummary("42"),
129129
Location: location.Location{
130130
File: "file2.go",
@@ -137,7 +137,7 @@ Originates from following error:
137137
Context: ctxerr.Context{
138138
Path: ctxerr.NewPath("DATA").AddArrayIndex(13).AddField("Field"),
139139
},
140-
Message: "Error message",
140+
Message: "error message",
141141
Summary: ctxerr.NewSummary("888"),
142142
Location: location.Location{
143143
File: "file.go",
@@ -147,19 +147,19 @@ Originates from following error:
147147
},
148148
}
149149
test.EqualStr(t, err.Error(),
150-
`DATA[12].Field: Error message
150+
`DATA[12].Field: error message
151151
666
152152
Originates from following error:
153-
DATA[12].Field<All#1/2>: Origin error message
153+
DATA[12].Field<All#1/2>: origin error message
154154
42
155155
[under operator SubOperator at file2.go:236]
156-
DATA[13].Field: Error message
156+
DATA[13].Field: error message
157157
888
158158
[under operator Operator at file.go:23]`)
159159

160160
err = ctxerr.Error{
161161
Context: ctxerr.Context{Path: ctxerr.NewPath("DATA").AddArrayIndex(12).AddField("Field")},
162-
Message: "Error message",
162+
Message: "error message",
163163
Summary: ctxerr.NewSummary("666"),
164164
Location: location.Location{
165165
File: "file.go",
@@ -170,7 +170,7 @@ DATA[13].Field: Error message
170170
Context: ctxerr.Context{
171171
Path: ctxerr.NewPath("DATA").AddArrayIndex(12).AddField("Field").AddCustomLevel("<All#1/2>"),
172172
},
173-
Message: "Origin error message",
173+
Message: "origin error message",
174174
Summary: ctxerr.NewSummary("42"),
175175
Location: location.Location{
176176
File: "file2.go",
@@ -183,7 +183,7 @@ DATA[13].Field: Error message
183183
Context: ctxerr.Context{
184184
Path: ctxerr.NewPath("DATA").AddArrayIndex(13).AddField("Field"),
185185
},
186-
Message: "Error message",
186+
Message: "error message",
187187
Summary: ctxerr.NewSummary("888"),
188188
Location: location.Location{
189189
File: "file.go",
@@ -193,14 +193,14 @@ DATA[13].Field: Error message
193193
},
194194
}
195195
test.EqualStr(t, err.Error(),
196-
`DATA[12].Field: Error message
196+
`DATA[12].Field: error message
197197
666
198198
Originates from following error:
199-
DATA[12].Field<All#1/2>: Origin error message
199+
DATA[12].Field<All#1/2>: origin error message
200200
42
201201
[under operator SubOperator at file2.go:236]
202202
[under operator Operator at file.go:23]
203-
DATA[13].Field: Error message
203+
DATA[13].Field: error message
204204
888
205205
[under operator Operator at file.go:24]`)
206206

internal/ctxerr/op_error.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func OpBadUsage(op, usage string, param interface{}, pos int, kind bool) *Error
4343
b.WriteString(" parameter")
4444

4545
return &Error{
46-
Message: "Bad usage of " + op + " operator",
46+
Message: "bad usage of " + op + " operator",
4747
Summary: NewSummary(b.String()),
4848
}
4949
}
@@ -52,7 +52,7 @@ func OpBadUsage(op, usage string, param interface{}, pos int, kind bool) *Error
5252
// variadic operator constructor with too many parameters.
5353
func OpTooManyParams(op, usage string) *Error {
5454
return &Error{
55-
Message: "Bad usage of " + op + " operator",
55+
Message: "bad usage of " + op + " operator",
5656
Summary: NewSummary("usage: " + op + usage + ", too many parameters"),
5757
}
5858
}
@@ -65,7 +65,7 @@ func OpBad(op, s string, args ...interface{}) *Error {
6565
s = fmt.Sprintf(s, args...)
6666
}
6767
return &Error{
68-
Message: "Bad usage of " + op + " operator",
68+
Message: "bad usage of " + op + " operator",
6969
Summary: NewSummary(s),
7070
}
7171
}

internal/ctxerr/op_error_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
"github.com/maxatome/go-testdeep/internal/test"
1515
)
1616

17-
const prefix = ": Bad usage of Zzz operator\n\t"
17+
const prefix = ": bad usage of Zzz operator\n\t"
1818

1919
func TestOpBadUsage(t *testing.T) {
2020
defer color.SaveState()()

td/td_array_test.go

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -168,55 +168,55 @@ func TestArray(t *testing.T) {
168168
checkError(t, "never tested",
169169
td.Array("test", nil),
170170
expectedError{
171-
Message: mustBe("Bad usage of Array operator"),
171+
Message: mustBe("bad usage of Array operator"),
172172
Path: mustBe("DATA"),
173173
Summary: mustBe("usage: Array(ARRAY|&ARRAY, EXPECTED_ENTRIES), but received string as 1st parameter"),
174174
})
175175

176176
checkError(t, "never tested",
177177
td.Array(&MyStruct{}, nil),
178178
expectedError{
179-
Message: mustBe("Bad usage of Array operator"),
179+
Message: mustBe("bad usage of Array operator"),
180180
Path: mustBe("DATA"),
181181
Summary: mustBe("usage: Array(ARRAY|&ARRAY, EXPECTED_ENTRIES), but received *td_test.MyStruct (ptr) as 1st parameter"),
182182
})
183183

184184
checkError(t, "never tested",
185185
td.Array([]int{}, nil),
186186
expectedError{
187-
Message: mustBe("Bad usage of Array operator"),
187+
Message: mustBe("bad usage of Array operator"),
188188
Path: mustBe("DATA"),
189189
Summary: mustBe("usage: Array(ARRAY|&ARRAY, EXPECTED_ENTRIES), but received []int (slice) as 1st parameter"),
190190
})
191191

192192
checkError(t, "never tested",
193193
td.Array([1]int{}, td.ArrayEntries{1: 34}),
194194
expectedError{
195-
Message: mustBe("Bad usage of Array operator"),
195+
Message: mustBe("bad usage of Array operator"),
196196
Path: mustBe("DATA"),
197197
Summary: mustBe("array length is 1, so cannot have #1 expected index"),
198198
})
199199

200200
checkError(t, "never tested",
201201
td.Array([3]int{}, td.ArrayEntries{1: nil}),
202202
expectedError{
203-
Message: mustBe("Bad usage of Array operator"),
203+
Message: mustBe("bad usage of Array operator"),
204204
Path: mustBe("DATA"),
205205
Summary: mustBe("expected value of #1 cannot be nil as items type is int"),
206206
})
207207

208208
checkError(t, "never tested",
209209
td.Array([3]int{}, td.ArrayEntries{1: "bad"}),
210210
expectedError{
211-
Message: mustBe("Bad usage of Array operator"),
211+
Message: mustBe("bad usage of Array operator"),
212212
Path: mustBe("DATA"),
213213
Summary: mustBe("type string of #1 expected value differs from array contents (int)"),
214214
})
215215

216216
checkError(t, "never tested",
217217
td.Array([1]int{12}, td.ArrayEntries{0: 21}),
218218
expectedError{
219-
Message: mustBe("Bad usage of Array operator"),
219+
Message: mustBe("bad usage of Array operator"),
220220
Path: mustBe("DATA"),
221221
Summary: mustBe("non zero #0 entry in model already exists in expectedEntries"),
222222
})
@@ -455,39 +455,39 @@ func TestSlice(t *testing.T) {
455455
checkError(t, "never tested",
456456
td.Slice("test", nil),
457457
expectedError{
458-
Message: mustBe("Bad usage of Slice operator"),
458+
Message: mustBe("bad usage of Slice operator"),
459459
Path: mustBe("DATA"),
460460
Summary: mustBe("usage: Slice(SLICE|&SLICE, EXPECTED_ENTRIES), but received string as 1st parameter"),
461461
})
462462

463463
checkError(t, "never tested",
464464
td.Slice(&MyStruct{}, nil),
465465
expectedError{
466-
Message: mustBe("Bad usage of Slice operator"),
466+
Message: mustBe("bad usage of Slice operator"),
467467
Path: mustBe("DATA"),
468468
Summary: mustBe("usage: Slice(SLICE|&SLICE, EXPECTED_ENTRIES), but received *td_test.MyStruct (ptr) as 1st parameter"),
469469
})
470470

471471
checkError(t, "never tested",
472472
td.Slice([0]int{}, nil),
473473
expectedError{
474-
Message: mustBe("Bad usage of Slice operator"),
474+
Message: mustBe("bad usage of Slice operator"),
475475
Path: mustBe("DATA"),
476476
Summary: mustBe("usage: Slice(SLICE|&SLICE, EXPECTED_ENTRIES), but received [0]int (array) as 1st parameter"),
477477
})
478478

479479
checkError(t, "never tested",
480480
td.Slice([]int{}, td.ArrayEntries{1: "bad"}),
481481
expectedError{
482-
Message: mustBe("Bad usage of Slice operator"),
482+
Message: mustBe("bad usage of Slice operator"),
483483
Path: mustBe("DATA"),
484484
Summary: mustBe("type string of #1 expected value differs from slice contents (int)"),
485485
})
486486

487487
checkError(t, "never tested",
488488
td.Slice([]int{12}, td.ArrayEntries{0: 21}),
489489
expectedError{
490-
Message: mustBe("Bad usage of Slice operator"),
490+
Message: mustBe("bad usage of Slice operator"),
491491
Path: mustBe("DATA"),
492492
Summary: mustBe("non zero #0 entry in model already exists in expectedEntries"),
493493
})
@@ -623,7 +623,7 @@ func TestSuperSliceOf(t *testing.T) {
623623
checkError(t, "never tested",
624624
td.SuperSliceOf(MyArray{}, td.ArrayEntries{8: 34}),
625625
expectedError{
626-
Message: mustBe("Bad usage of SuperSliceOf operator"),
626+
Message: mustBe("bad usage of SuperSliceOf operator"),
627627
Path: mustBe("DATA"),
628628
Summary: mustBe("array length is 5, so cannot have #8 expected index"),
629629
})
@@ -701,31 +701,31 @@ func TestSuperSliceOf(t *testing.T) {
701701
checkError(t, "never tested",
702702
td.SuperSliceOf("test", nil),
703703
expectedError{
704-
Message: mustBe("Bad usage of SuperSliceOf operator"),
704+
Message: mustBe("bad usage of SuperSliceOf operator"),
705705
Path: mustBe("DATA"),
706706
Summary: mustBe("usage: SuperSliceOf(ARRAY|&ARRAY|SLICE|&SLICE, EXPECTED_ENTRIES), but received string as 1st parameter"),
707707
})
708708

709709
checkError(t, "never tested",
710710
td.SuperSliceOf(&MyStruct{}, nil),
711711
expectedError{
712-
Message: mustBe("Bad usage of SuperSliceOf operator"),
712+
Message: mustBe("bad usage of SuperSliceOf operator"),
713713
Path: mustBe("DATA"),
714714
Summary: mustBe("usage: SuperSliceOf(ARRAY|&ARRAY|SLICE|&SLICE, EXPECTED_ENTRIES), but received *td_test.MyStruct (ptr) as 1st parameter"),
715715
})
716716

717717
checkError(t, "never tested",
718718
td.SuperSliceOf([]int{}, td.ArrayEntries{1: "bad"}),
719719
expectedError{
720-
Message: mustBe("Bad usage of SuperSliceOf operator"),
720+
Message: mustBe("bad usage of SuperSliceOf operator"),
721721
Path: mustBe("DATA"),
722722
Summary: mustBe("type string of #1 expected value differs from slice contents (int)"),
723723
})
724724

725725
checkError(t, "never tested",
726726
td.SuperSliceOf([]int{12}, td.ArrayEntries{0: 21}),
727727
expectedError{
728-
Message: mustBe("Bad usage of SuperSliceOf operator"),
728+
Message: mustBe("bad usage of SuperSliceOf operator"),
729729
Path: mustBe("DATA"),
730730
Summary: mustBe("non zero #0 entry in model already exists in expectedEntries"),
731731
})

0 commit comments

Comments
 (0)