♻️ Use defined errors
This commit is contained in:
parent
5b60305de7
commit
2d68691408
5 changed files with 34 additions and 20 deletions
|
|
@ -32,7 +32,7 @@ func TestMeta(t *testing.T) {
|
|||
{"json number", "num", json.Number("42.13"), "@num 42.13", nil, 42.13},
|
||||
{"true", "b", true, "@b true", nil, true},
|
||||
{"false", "b", false, "@b false", nil, false},
|
||||
{"nil", "n", nil, "", nil, errors.New("Unable to Unmarshal empty string")},
|
||||
{"nil", "n", nil, "", nil, ErrorParsing},
|
||||
{"time", "when", when, "@when " + when.Format(time.RFC3339), nil, when},
|
||||
{"rune", "char", '@', "@char @", nil, "@"},
|
||||
{"bytes", "byteme", []byte("yo"), "@byteme yo", nil, "yo"},
|
||||
|
|
@ -41,11 +41,11 @@ func TestMeta(t *testing.T) {
|
|||
{"json-arr", "arr", json.RawMessage(`["foo",42,"bar", null,"quux", true]`), `@arr ["foo",42,"bar", null,"quux", true]`, nil, json.RawMessage(`["foo",42,"bar", null,"quux", true]`)},
|
||||
{"chan", "nope", make(chan bool), "", errors.New("Unknown type chan bool"), ""},
|
||||
{"whitespace-key", "no space", "hi", "", errors.New("whitespace is not allowed in key: no space"), ""},
|
||||
{"empty-mar", "nope", skipMarshalTest, "", nil, errors.New("Unable to Unmarshal empty string")},
|
||||
{"no-key-mar", "nope", skipMarshalTest, "nope", nil, errors.New("Failed to match nope")},
|
||||
{"no-value-mar", "nope", skipMarshalTest, "@nope ", nil, errors.New("No value found")},
|
||||
{"space-value-mar", "nope", skipMarshalTest, "@nope ", nil, errors.New("No value found")},
|
||||
{"space-value-mar", "nope", skipMarshalTest, "@nope \n ", nil, errors.New("No value found")},
|
||||
{"empty-mar", "nope", skipMarshalTest, "", nil, ErrorParsing},
|
||||
{"no-key-mar", "nope", skipMarshalTest, "nope", nil, ErrorParsing},
|
||||
{"no-value-mar", "nope", skipMarshalTest, "@nope ", nil, ErrorParsing},
|
||||
{"space-value-mar", "nope", skipMarshalTest, "@nope ", nil, ErrorParsing},
|
||||
{"space-nl-value-mar", "nope", skipMarshalTest, "@nope \n ", nil, ErrorParsing},
|
||||
{"null-value-mar", "nope", skipMarshalTest, "@nope null", nil, nil},
|
||||
{"tilda-value-mar", "nope", skipMarshalTest, "@nope ~", nil, nil},
|
||||
{"none-value-mar", "nope", skipMarshalTest, "@nope none", nil, nil},
|
||||
|
|
@ -81,7 +81,7 @@ func getMetaTestRunner(key string, value any, out string, err error, newVal any)
|
|||
e = n.UnmarshalText([]byte(out))
|
||||
}
|
||||
if newE, ok := newVal.(error); ok {
|
||||
assert.Equal(t, newE, e)
|
||||
assert.ErrorIs(t, e, newE)
|
||||
} else {
|
||||
assert.Equal(t, key, n.Key)
|
||||
if ti, ok := newVal.(time.Time); ok {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue