mirror of
https://github.com/gogs/gogs.git
synced 2026-01-12 02:12:20 +01:00
Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
38 lines
852 B
Go
38 lines
852 B
Go
package gitutil
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
|
|
"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))
|
|
}
|
|
|
|
func TestIsErrNoMergeBase(t *testing.T) {
|
|
assert.True(t, IsErrNoMergeBase(git.ErrNoMergeBase))
|
|
assert.False(t, IsErrNoMergeBase(os.ErrNotExist))
|
|
}
|