/
githubmirror
/
gogs
Обзор
Документация
Войти
/
githubmirror
/
gogs
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
internal/errx/errx_test.go
49 строк
856 B
ᴊᴏᴇ ᴄʜᴇɴ
all: rename packages ending with "util" to end with "x" (#8182)
16 фев 2026, 21:25
Не верифицирован
16 фев 2026, 21:25
36d56d5
Код
Авторство
О чём код?
package errx import ( "testing" "github.com/cockroachdb/errors" "github.com/stretchr/testify/assert" ) type notFoundError struct { val bool } func (notFoundError) Error() string { return "not found" } func (e notFoundError) NotFound() bool { return e.val } func TestIsNotFound(t *testing.T) { tests := []struct { name string err error expVal bool }{ { name: "error does not implement NotFound", err: errors.New("a simple error"), expVal: false, }, { name: "error implements NotFound but not a not found", err: notFoundError{val: false}, expVal: false, }, { name: "error implements NotFound", err: notFoundError{val: true}, expVal: true, }, } for _, test := range tests { t.Run(test.name, func(t *testing.T) { assert.Equal(t, test.expVal, IsNotFound(test.err)) }) } }