Compare commits

...

2 Commits

Author SHA1 Message Date
bandl 77cde0b2ef test(test-test): add test 2021-08-21 21:38:06 +08:00
bandl 3709b6f8e5 feat(test-test): add test func 2021-08-21 21:20:13 +08:00
2 changed files with 35 additions and 0 deletions

17
pkg/lru/lru/lru.go Normal file
View File

@ -0,0 +1,17 @@
package lru
import (
"strconv"
"time"
)
// 保证所有函数和变量最小作用域
func Test(a int) (string, error) {
// awd
return strconv.Itoa(a), nil
}
func Nows() string {
return time.Now().Format("2006-01-02")
}

18
pkg/lru/lru/lru_test.go Normal file
View File

@ -0,0 +1,18 @@
package lru
import (
"github.com/stretchr/testify/require"
"testing"
)
func TestTest(t *testing.T) {
ts , err := Test(2)
require.NoError(t, err)
require.Regexp(t, `\d`, ts)
ts, err = Test(3)
require.NoError(t, err)
require.Equal(t, "3", ts)
require.Regexp(t, `\d{4}-\d{2}-\d{2}`, Nows())
}