mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Enable addtional linters (#34085)
enable mirror, usestdlibbars and perfsprint part of: https://github.com/go-gitea/gitea/issues/34083 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
10
modules/cache/cache.go
vendored
10
modules/cache/cache.go
vendored
@@ -4,6 +4,8 @@
|
||||
package cache
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"time"
|
||||
@@ -48,10 +50,10 @@ const (
|
||||
// returns
|
||||
func Test() (time.Duration, error) {
|
||||
if defaultCache == nil {
|
||||
return 0, fmt.Errorf("default cache not initialized")
|
||||
return 0, errors.New("default cache not initialized")
|
||||
}
|
||||
|
||||
testData := fmt.Sprintf("%x", make([]byte, 500))
|
||||
testData := hex.EncodeToString(make([]byte, 500))
|
||||
|
||||
start := time.Now()
|
||||
|
||||
@@ -63,10 +65,10 @@ func Test() (time.Duration, error) {
|
||||
}
|
||||
testVal, hit := defaultCache.Get(testCacheKey)
|
||||
if !hit {
|
||||
return 0, fmt.Errorf("expect cache hit but got none")
|
||||
return 0, errors.New("expect cache hit but got none")
|
||||
}
|
||||
if testVal != testData {
|
||||
return 0, fmt.Errorf("expect cache to return same value as stored but got other")
|
||||
return 0, errors.New("expect cache to return same value as stored but got other")
|
||||
}
|
||||
|
||||
return time.Since(start), nil
|
||||
|
10
modules/cache/cache_test.go
vendored
10
modules/cache/cache_test.go
vendored
@@ -4,7 +4,7 @@
|
||||
package cache
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"errors"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -57,7 +57,7 @@ func TestGetString(t *testing.T) {
|
||||
createTestCache()
|
||||
|
||||
data, err := GetString("key", func() (string, error) {
|
||||
return "", fmt.Errorf("some error")
|
||||
return "", errors.New("some error")
|
||||
})
|
||||
assert.Error(t, err)
|
||||
assert.Empty(t, data)
|
||||
@@ -82,7 +82,7 @@ func TestGetString(t *testing.T) {
|
||||
assert.Equal(t, "some data", data)
|
||||
|
||||
data, err = GetString("key", func() (string, error) {
|
||||
return "", fmt.Errorf("some error")
|
||||
return "", errors.New("some error")
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "some data", data)
|
||||
@@ -93,7 +93,7 @@ func TestGetInt64(t *testing.T) {
|
||||
createTestCache()
|
||||
|
||||
data, err := GetInt64("key", func() (int64, error) {
|
||||
return 0, fmt.Errorf("some error")
|
||||
return 0, errors.New("some error")
|
||||
})
|
||||
assert.Error(t, err)
|
||||
assert.EqualValues(t, 0, data)
|
||||
@@ -118,7 +118,7 @@ func TestGetInt64(t *testing.T) {
|
||||
assert.EqualValues(t, 100, data)
|
||||
|
||||
data, err = GetInt64("key", func() (int64, error) {
|
||||
return 0, fmt.Errorf("some error")
|
||||
return 0, errors.New("some error")
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, 100, data)
|
||||
|
Reference in New Issue
Block a user