lib/errors: Assert warning against nil error in tests (#40631)

This commit is contained in:
Indradhanush Gupta 2022-08-22 21:31:43 +05:30 committed by GitHub
parent 066baf25a7
commit e2ae15ea28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,8 +5,15 @@ import (
)
func TestWarningError(t *testing.T) {
err := New("foo")
var ref Warning
var err error
// Ensure that a nil error is not a warning type error.
if As(err, &ref) {
t.Error(`Expected nil error to NOT be of type warning`)
}
err = New("foo")
// Ensure that all errors are not a warning type error.
if As(err, &ref) {