mirror of
https://github.com/go-gitea/gitea.git
synced 2026-09-05 04:23:24 +09:00
enhance: Improve validation errors for secrets/variables (#39221)
Signed-off-by: Ross Golder <ross@golder.org> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
co-authored by
wxiaoguang
parent
ce2fd8d882
commit
2d3ad4a530
@@ -4,6 +4,7 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
@@ -32,3 +33,19 @@ func TestErrorTranslatable(t *testing.T) {
|
||||
require.True(t, ok)
|
||||
assert.Equal(t, "key", wrapped.trKey)
|
||||
}
|
||||
|
||||
func TestErrorUnwrapForUser(t *testing.T) {
|
||||
err := NewNotExistErrorf("test msg")
|
||||
msg, code := ErrorUnwrapForUser(err)
|
||||
assert.Equal(t, "test msg", msg)
|
||||
assert.Equal(t, 404, code)
|
||||
|
||||
err = fmt.Errorf("other wrapper: %w", err)
|
||||
msg, code = ErrorUnwrapForUser(err)
|
||||
assert.Equal(t, "other wrapper: test msg", msg)
|
||||
assert.Equal(t, 404, code)
|
||||
|
||||
msg, code = ErrorUnwrapForUser(io.EOF)
|
||||
assert.Equal(t, "", msg)
|
||||
assert.Equal(t, 0, code)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user