Skip to content

Commit 9a05823

Browse files
generatedunixname2655515034848748meta-codesync[bot]
authored andcommitted
fbcode/openbmc/openbmc/tools/flashy/lib/utils/helper_test.go
Reviewed By: echistyakov Differential Revision: D92817912 fbshipit-source-id: 488bdccd3112f5a9e33e93a4635769088d8d701f
1 parent cc62558 commit 9a05823

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

tools/flashy/lib/utils/helper_test.go

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ package utils
2121

2222
import (
2323
"bytes"
24+
"fmt"
2425
"math"
2526
"reflect"
2627
"sort"
2728
"testing"
2829

2930
"github.com/facebook/openbmc/tools/flashy/tests"
30-
"github.com/pkg/errors"
3131
)
3232

3333
func TestStringFind(t *testing.T) {
@@ -142,7 +142,7 @@ func TestRegexSubexpMapHelper(t *testing.T) {
142142
match: []string{"", "foo"},
143143
subexpNames: []string{"", "F", "B"},
144144
want: map[string]string{},
145-
wantErr: errors.Errorf("Incomplete match '%#v' for subexpNames '%#v'",
145+
wantErr: fmt.Errorf("Incomplete match '%#v' for subexpNames '%#v'",
146146
[]string{"", "foo"}, []string{"", "F", "B"}),
147147
},
148148
{
@@ -159,15 +159,15 @@ func TestRegexSubexpMapHelper(t *testing.T) {
159159
want: map[string]string{
160160
"f": "foo",
161161
},
162-
wantErr: errors.Errorf("Duplicate subexpName 'f' found. Make sure " +
162+
wantErr: fmt.Errorf("Duplicate subexpName 'f' found. Make sure " +
163163
"the regEx capturing group names are unique."),
164164
},
165165
{
166166
name: "empty subexpName",
167167
match: []string{"", "foo"},
168168
subexpNames: []string{"", ""},
169169
want: map[string]string{},
170-
wantErr: errors.Errorf("Invalid empty subexpName, subexpNames must have " +
170+
wantErr: fmt.Errorf("Invalid empty subexpName, subexpNames must have " +
171171
"non-empty strings (except for the 1st entry)"),
172172
},
173173
}
@@ -206,14 +206,14 @@ func TestGetRegexSubexpMap(t *testing.T) {
206206
regEx: `(?P<type>[a-z]+)`,
207207
input: "123",
208208
want: map[string]string{},
209-
wantErr: errors.Errorf("No match for regex '(?P<type>[a-z]+)' for input '123'"),
209+
wantErr: fmt.Errorf("No match for regex '(?P<type>[a-z]+)' for input '123'"),
210210
},
211211
{
212212
name: "multiple groups, no match",
213213
regEx: `(?P<type>[a-z]+):(?P<specifier>[0-9]+)`,
214214
input: "123mtdabc:abc",
215215
want: map[string]string{},
216-
wantErr: errors.Errorf("No match for regex '(?P<type>[a-z]+):(?P<specifier>[0-9]+)' " +
216+
wantErr: fmt.Errorf("No match for regex '(?P<type>[a-z]+):(?P<specifier>[0-9]+)' " +
217217
"for input '123mtdabc:abc'"),
218218
},
219219
{
@@ -239,14 +239,14 @@ func TestGetRegexSubexpMap(t *testing.T) {
239239
regEx: `(?P<type>[a-z]+`,
240240
input: "123mtdabc:123abc",
241241
want: map[string]string{},
242-
wantErr: errors.Errorf("error parsing regexp: missing closing ): `(?P<type>[a-z]+`"),
242+
wantErr: fmt.Errorf("error parsing regexp: missing closing ): `(?P<type>[a-z]+`"),
243243
},
244244
{
245245
name: "Invalid empty pattern",
246246
regEx: `(?P<type>[a-z]+):(?P<>[0-9]+)`,
247247
input: "123mtdabc:123abc",
248248
want: map[string]string{},
249-
wantErr: errors.Errorf("error parsing regexp: invalid named capture: `(?P<>`"),
249+
wantErr: fmt.Errorf("error parsing regexp: invalid named capture: `(?P<>`"),
250250
},
251251
{
252252
name: "Duplicate capturing group name",
@@ -255,15 +255,15 @@ func TestGetRegexSubexpMap(t *testing.T) {
255255
want: map[string]string{
256256
"type": "mtdabc",
257257
},
258-
wantErr: errors.Errorf("Duplicate subexpName 'type' found. " +
258+
wantErr: fmt.Errorf("Duplicate subexpName 'type' found. " +
259259
"Make sure the regEx capturing group names are unique."),
260260
},
261261
{
262262
name: "Called with regex with unnamed parenthesized group",
263263
regEx: `a(x*)b`,
264264
input: "-ab-",
265265
want: map[string]string{},
266-
wantErr: errors.Errorf("Invalid empty subexpName, subexpNames must have non-empty strings " +
266+
wantErr: fmt.Errorf("Invalid empty subexpName, subexpNames must have non-empty strings " +
267267
"(except for the 1st entry)"),
268268
},
269269
}
@@ -301,14 +301,14 @@ func TestGetBytesRegexSubexpMap(t *testing.T) {
301301
regEx: `(?P<type>[a-z]+)`,
302302
input: "123",
303303
want: map[string]string{},
304-
wantErr: errors.Errorf("No match for regex '(?P<type>[a-z]+)' for input"),
304+
wantErr: fmt.Errorf("No match for regex '(?P<type>[a-z]+)' for input"),
305305
},
306306
{
307307
name: "multiple groups, no match",
308308
regEx: `(?P<type>[a-z]+):(?P<specifier>[0-9]+)`,
309309
input: "123mtdabc:abc",
310310
want: map[string]string{},
311-
wantErr: errors.Errorf("No match for regex '(?P<type>[a-z]+):(?P<specifier>[0-9]+)' " +
311+
wantErr: fmt.Errorf("No match for regex '(?P<type>[a-z]+):(?P<specifier>[0-9]+)' " +
312312
"for input"),
313313
},
314314
{
@@ -334,14 +334,14 @@ func TestGetBytesRegexSubexpMap(t *testing.T) {
334334
regEx: `(?P<type>[a-z]+`,
335335
input: "123mtdabc:123abc",
336336
want: map[string]string{},
337-
wantErr: errors.Errorf("error parsing regexp: missing closing ): `(?P<type>[a-z]+`"),
337+
wantErr: fmt.Errorf("error parsing regexp: missing closing ): `(?P<type>[a-z]+`"),
338338
},
339339
{
340340
name: "Invalid empty pattern",
341341
regEx: `(?P<type>[a-z]+):(?P<>[0-9]+)`,
342342
input: "123mtdabc:123abc",
343343
want: map[string]string{},
344-
wantErr: errors.Errorf("error parsing regexp: invalid named capture: `(?P<>`"),
344+
wantErr: fmt.Errorf("error parsing regexp: invalid named capture: `(?P<>`"),
345345
},
346346
{
347347
name: "Duplicate capturing group name",
@@ -350,15 +350,15 @@ func TestGetBytesRegexSubexpMap(t *testing.T) {
350350
want: map[string]string{
351351
"type": "mtdabc",
352352
},
353-
wantErr: errors.Errorf("Duplicate subexpName 'type' found. " +
353+
wantErr: fmt.Errorf("Duplicate subexpName 'type' found. " +
354354
"Make sure the regEx capturing group names are unique."),
355355
},
356356
{
357357
name: "Called with regex with unnamed parenthesized group",
358358
regEx: `a(x*)b`,
359359
input: "-ab-",
360360
want: map[string]string{},
361-
wantErr: errors.Errorf("Invalid empty subexpName, subexpNames must have non-empty strings " +
361+
wantErr: fmt.Errorf("Invalid empty subexpName, subexpNames must have non-empty strings " +
362362
"(except for the 1st entry)"),
363363
},
364364
}
@@ -427,7 +427,7 @@ func TestGetAllRegexSubexpMap(t *testing.T) {
427427
regEx: `(?P<type>[a-z]+`,
428428
input: `mtd:flash0`,
429429
want: [](map[string]string){},
430-
wantErr: errors.Errorf("error parsing regexp: missing closing ): `(?P<type>[a-z]+`"),
430+
wantErr: fmt.Errorf("error parsing regexp: missing closing ): `(?P<type>[a-z]+`"),
431431
},
432432
}
433433

@@ -493,14 +493,14 @@ func TestGetWord(t *testing.T) {
493493
data: []byte{0x01, 0x02, 0x03, 0x04},
494494
offset: 2,
495495
want: 0,
496-
wantErr: errors.Errorf("Failed to get bytes for word: Slice end (6) larger than original slice length (4)"),
496+
wantErr: fmt.Errorf("Failed to get bytes for word: Slice end (6) larger than original slice length (4)"),
497497
},
498498
{
499499
name: "overflowed",
500500
data: []byte{0x01, 0x02, 0x03, 0x04},
501501
offset: math.MaxUint32 - 3,
502502
want: 0,
503-
wantErr: errors.Errorf("Failed to get end of offset: Unsigned integer overflow for (4294967292+4)"),
503+
wantErr: fmt.Errorf("Failed to get end of offset: Unsigned integer overflow for (4294967292+4)"),
504504
},
505505
}
506506
for _, tc := range cases {
@@ -537,7 +537,7 @@ func TestSetWord(t *testing.T) {
537537
word: 0x12345678,
538538
offset: 2,
539539
want: nil,
540-
wantErr: errors.Errorf("Required offset %v out of range of data size %v",
540+
wantErr: fmt.Errorf("Required offset %v out of range of data size %v",
541541
2, 4),
542542
},
543543
{
@@ -546,7 +546,7 @@ func TestSetWord(t *testing.T) {
546546
word: 0x12345678,
547547
offset: math.MaxUint32 - 3,
548548
want: nil,
549-
wantErr: errors.Errorf("Failed to get end of offset: Unsigned integer overflow for (4294967292+4)"),
549+
wantErr: fmt.Errorf("Failed to get end of offset: Unsigned integer overflow for (4294967292+4)"),
550550
},
551551
}
552552
for _, tc := range cases {
@@ -598,7 +598,7 @@ func TestGetStringKeysFromJSONData(t *testing.T) {
598598
name: "gibberish, no JSON",
599599
data: []byte("1254yewruifhqreifriqfhru43r4"),
600600
want: nil,
601-
wantErr: errors.Errorf("Unable to unmarshal JSON: " +
601+
wantErr: fmt.Errorf("Unable to unmarshal JSON: " +
602602
"invalid character 'y' after top-level value"),
603603
},
604604
}

0 commit comments

Comments
 (0)