aboutsummaryrefslogtreecommitdiff
path: root/internal/gitutil
diff options
context:
space:
mode:
authorᴜɴᴋɴᴡᴏɴ <u@gogs.io>2020-03-16 01:54:08 +0800
committerGitHub <noreply@github.com>2020-03-16 01:54:08 +0800
commita4de85dc806f6b7e344eb5bf8424ef2bb4815571 (patch)
tree57d8e290f9ccc8002629c9039efd469b689b649a /internal/gitutil
parent9e9ca66467116e9079a2639c00e9e623aca23015 (diff)
util: add tests (#5989)
Diffstat (limited to 'internal/gitutil')
-rw-r--r--internal/gitutil/error_test.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/internal/gitutil/error_test.go b/internal/gitutil/error_test.go
index c0b9f77a..331751f1 100644
--- a/internal/gitutil/error_test.go
+++ b/internal/gitutil/error_test.go
@@ -10,8 +10,26 @@ import (
"github.com/gogs/git-module"
"github.com/stretchr/testify/assert"
+
+ "gogs.io/gogs/internal/errutil"
)
+func TestError_NotFound(t *testing.T) {
+ tests := []struct {
+ err error
+ expVal bool
+ }{
+ {err: git.ErrSubmoduleNotExist, expVal: true},
+ {err: git.ErrRevisionNotExist, expVal: true},
+ {err: git.ErrNoMergeBase, expVal: false},
+ }
+ for _, test := range tests {
+ t.Run("", func(t *testing.T) {
+ assert.Equal(t, test.expVal, errutil.IsNotFound(NewError(test.err)))
+ })
+ }
+}
+
func TestIsErrRevisionNotExist(t *testing.T) {
assert.True(t, IsErrRevisionNotExist(git.ErrRevisionNotExist))
assert.False(t, IsErrRevisionNotExist(os.ErrNotExist))