mirror of
https://github.com/vbatts/go-mtree.git
synced 2025-10-04 04:31:00 +00:00
govis: modernise errors
This code was written before %w was added to Go, and there were a fair few mistakes in the copy-pasted error code. Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
This commit is contained in:
parent
3ce83fca15
commit
fbada2e081
4 changed files with 89 additions and 58 deletions
|
@ -215,3 +215,21 @@ func TestVisFlagsString(t *testing.T) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestUnknownVisFlagsError(t *testing.T) {
|
||||
t.Run("Vis", func(t *testing.T) {
|
||||
enc, err := Vis("dummy text", visMask+1)
|
||||
require.Error(t, err, "Vis with invalid flags should fail")
|
||||
assert.ErrorIs(t, err, errUnknownVisFlagsError, "Vis with invalid flags")
|
||||
assert.ErrorContains(t, err, "contains unknown or unsupported flags", "Vis with invalid flags")
|
||||
assert.Equal(t, "", enc, "error Vis should return empty string")
|
||||
})
|
||||
|
||||
t.Run("Unvis", func(t *testing.T) {
|
||||
dec, err := Unvis("dummy text", visMask+1)
|
||||
require.Error(t, err, "Unvis with invalid flags should fail")
|
||||
assert.ErrorIs(t, err, errUnknownVisFlagsError, "Unvis with invalid flags")
|
||||
assert.ErrorContains(t, err, "contains unknown or unsupported flags", "Vis with invalid flags")
|
||||
assert.Equal(t, "", dec, "error Unvis should return empty string")
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue