fixt tests
This commit is contained in:
parent
998913763e
commit
e394e75ffa
12 changed files with 40 additions and 11 deletions
2
.github/workflows/build-linux.yml
vendored
2
.github/workflows/build-linux.yml
vendored
|
|
@ -13,7 +13,7 @@ jobs:
|
||||||
build:
|
build:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
go: [1.19.2]
|
go: [1.21.1]
|
||||||
runs-on: "ubuntu-20.04"
|
runs-on: "ubuntu-20.04"
|
||||||
steps:
|
steps:
|
||||||
- name: Arm Build
|
- name: Arm Build
|
||||||
|
|
|
||||||
2
.github/workflows/build-macos.yml
vendored
2
.github/workflows/build-macos.yml
vendored
|
|
@ -13,7 +13,7 @@ jobs:
|
||||||
build:
|
build:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
go: [1.19.2]
|
go: [1.21.1]
|
||||||
runs-on: "macos-12"
|
runs-on: "macos-12"
|
||||||
steps:
|
steps:
|
||||||
- name: Install coscmd
|
- name: Install coscmd
|
||||||
|
|
|
||||||
2
.github/workflows/pr-test.yml
vendored
2
.github/workflows/pr-test.yml
vendored
|
|
@ -66,7 +66,7 @@ jobs:
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
go: [1.19.5, 1.20.0]
|
go: [1.20.0, 1.21.1]
|
||||||
db: [MySQL8.0, MySQL5.7, SQLite3]
|
db: [MySQL8.0, MySQL5.7, SQLite3]
|
||||||
redis: [4, 5, 6]
|
redis: [4, 5, 6]
|
||||||
mongo: ["6.0"]
|
mongo: ["6.0"]
|
||||||
|
|
|
||||||
2
.github/workflows/unit-test.yml
vendored
2
.github/workflows/unit-test.yml
vendored
|
|
@ -70,7 +70,7 @@ jobs:
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
go: [1.19.5, 1.20.0]
|
go: [1.20.0, 1.21.1]
|
||||||
db: [MySQL8.0, MySQL5.7, SQLite3]
|
db: [MySQL8.0, MySQL5.7, SQLite3]
|
||||||
redis: [4, 5, 6]
|
redis: [4, 5, 6]
|
||||||
mongo: ["6.0"]
|
mongo: ["6.0"]
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,10 @@ func init() {
|
||||||
process.Alias("xiang.main.Inspect", "xiang.sys.Inspect") // deprecated
|
process.Alias("xiang.main.Inspect", "xiang.sys.Inspect") // deprecated
|
||||||
|
|
||||||
process.Register("xiang.main.Favicon", processFavicon) // deprecated
|
process.Register("xiang.main.Favicon", processFavicon) // deprecated
|
||||||
|
|
||||||
|
// Application
|
||||||
|
process.Alias("xiang.main.Ping", "utils.app.Ping")
|
||||||
|
process.Alias("xiang.main.Inspect", "utils.app.Inspect")
|
||||||
}
|
}
|
||||||
|
|
||||||
// processCreate 运行模型 MustCreate
|
// processCreate 运行模型 MustCreate
|
||||||
|
|
|
||||||
2
go.mod
2
go.mod
|
|
@ -1,6 +1,6 @@
|
||||||
module github.com/yaoapp/yao
|
module github.com/yaoapp/yao
|
||||||
|
|
||||||
go 1.19
|
go 1.20
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/blang/semver v3.5.1+incompatible
|
github.com/blang/semver v3.5.1+incompatible
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ func TestFingerprintSimple(t *testing.T) {
|
||||||
|
|
||||||
imp := Select("order")
|
imp := Select("order")
|
||||||
fingerprint := imp.Fingerprint(file)
|
fingerprint := imp.Fingerprint(file)
|
||||||
assert.Equal(t, "3451ca87d71801687abba8993e5a69af79482914435d7cc064236fd93160f999", fingerprint)
|
assert.Equal(t, "2187b40d1e1819ffc27114caf0e80655fe44ffc4e072b07ec18611ca23951ac4", fingerprint)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAutoMappingSimple(t *testing.T) {
|
func TestAutoMappingSimple(t *testing.T) {
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ import (
|
||||||
"github.com/yaoapp/yao/helper"
|
"github.com/yaoapp/yao/helper"
|
||||||
"github.com/yaoapp/yao/runtime"
|
"github.com/yaoapp/yao/runtime"
|
||||||
"github.com/yaoapp/yao/share"
|
"github.com/yaoapp/yao/share"
|
||||||
|
"github.com/yaoapp/yao/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
var testServer *http.Server = nil
|
var testServer *http.Server = nil
|
||||||
|
|
@ -73,6 +74,7 @@ func Prepare(t *testing.T, cfg config.Config) {
|
||||||
cfg.DataRoot = filepath.Join(root, "data")
|
cfg.DataRoot = filepath.Join(root, "data")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
utils.Init()
|
||||||
dbconnect(t, cfg)
|
dbconnect(t, cfg)
|
||||||
load(t, cfg)
|
load(t, cfg)
|
||||||
startRuntime(t, cfg)
|
startRuntime(t, cfg)
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,35 @@ import (
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/yaoapp/gou/process"
|
"github.com/yaoapp/gou/process"
|
||||||
|
_ "github.com/yaoapp/yao/helper"
|
||||||
|
"github.com/yaoapp/yao/utils/datetime"
|
||||||
|
"github.com/yaoapp/yao/utils/str"
|
||||||
|
"github.com/yaoapp/yao/utils/tree"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestProcessNow(t *testing.T) {
|
func TestProcessNow(t *testing.T) {
|
||||||
|
testPrepare()
|
||||||
assert.LessOrEqual(t, time.Now().Unix(), process.New("utils.now.Timestamp").Run().(int64))
|
assert.LessOrEqual(t, time.Now().Unix(), process.New("utils.now.Timestamp").Run().(int64))
|
||||||
assert.LessOrEqual(t, time.Now().UnixMilli(), process.New("utils.now.Timestampms").Run().(int64))
|
assert.LessOrEqual(t, time.Now().UnixMilli(), process.New("utils.now.Timestampms").Run().(int64))
|
||||||
assert.NotNil(t, process.New("utils.now.Date").Run())
|
assert.NotNil(t, process.New("utils.now.Date").Run())
|
||||||
assert.NotNil(t, process.New("utils.now.Time").Run())
|
assert.NotNil(t, process.New("utils.now.Time").Run())
|
||||||
assert.NotNil(t, process.New("utils.now.DateTime").Run())
|
assert.NotNil(t, process.New("utils.now.DateTime").Run())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func testPrepare() {
|
||||||
|
|
||||||
|
// Tree
|
||||||
|
process.Register("utils.tree.Flatten", tree.ProcessFlatten)
|
||||||
|
|
||||||
|
process.Alias("xiang.helper.StrConcat", "utils.str.Concat")
|
||||||
|
process.Alias("xiang.helper.HexToString", "utils.str.Hex")
|
||||||
|
process.Register("utils.str.Join", str.ProcessJoin)
|
||||||
|
process.Register("utils.str.JoinPath", str.ProcessJoinPath)
|
||||||
|
process.Register("utils.str.UUID", str.ProcessUUID)
|
||||||
|
|
||||||
|
process.Register("utils.now.Time", datetime.ProcessTime)
|
||||||
|
process.Register("utils.now.Date", datetime.ProcessDate)
|
||||||
|
process.Register("utils.now.DateTime", datetime.ProcessDateTime)
|
||||||
|
process.Register("utils.now.Timestamp", datetime.ProcessTimestamp)
|
||||||
|
process.Register("utils.now.Timestampms", datetime.ProcessTimestampms)
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,10 +16,6 @@ func Init() {
|
||||||
// * Migrate Processes Version 0.10.2+
|
// * Migrate Processes Version 0.10.2+
|
||||||
// ****************************************
|
// ****************************************
|
||||||
|
|
||||||
// Application
|
|
||||||
process.Alias("xiang.main.Ping", "utils.app.Ping")
|
|
||||||
process.Alias("xiang.main.Inspect", "utils.app.Inspect")
|
|
||||||
|
|
||||||
// FMT
|
// FMT
|
||||||
process.Alias("xiang.helper.Print", "utils.fmt.Print")
|
process.Alias("xiang.helper.Print", "utils.fmt.Print")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,17 +12,20 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestProcessStrJoin(t *testing.T) {
|
func TestProcessStrJoin(t *testing.T) {
|
||||||
|
testPrepare()
|
||||||
res := process.New("utils.str.Join", []interface{}{"FOO", 20, "BAR"}, ",").Run().(string)
|
res := process.New("utils.str.Join", []interface{}{"FOO", 20, "BAR"}, ",").Run().(string)
|
||||||
assert.Equal(t, "FOO,20,BAR", res)
|
assert.Equal(t, "FOO,20,BAR", res)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestProcessStrJoinPath(t *testing.T) {
|
func TestProcessStrJoinPath(t *testing.T) {
|
||||||
|
testPrepare()
|
||||||
res := process.New("utils.str.JoinPath", "data", 20, "app").Run().(string)
|
res := process.New("utils.str.JoinPath", "data", 20, "app").Run().(string)
|
||||||
shouldBe := fmt.Sprintf("data%s20%sapp", string(os.PathSeparator), string(os.PathSeparator))
|
shouldBe := fmt.Sprintf("data%s20%sapp", string(os.PathSeparator), string(os.PathSeparator))
|
||||||
assert.Equal(t, shouldBe, res)
|
assert.Equal(t, shouldBe, res)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestProcessUUID(t *testing.T) {
|
func TestProcessUUID(t *testing.T) {
|
||||||
|
testPrepare()
|
||||||
res := process.New("utils.str.UUID").Run().(string)
|
res := process.New("utils.str.UUID").Run().(string)
|
||||||
_, err := uuid.Parse(res)
|
_, err := uuid.Parse(res)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -33,6 +36,7 @@ func TestProcessUUID(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestProcessStrHex(t *testing.T) {
|
func TestProcessStrHex(t *testing.T) {
|
||||||
|
testPrepare()
|
||||||
res, err := process.New("utils.str.Hex", []byte{0x0, 0x1}).Exec()
|
res, err := process.New("utils.str.Hex", []byte{0x0, 0x1}).Exec()
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
assert.Equal(t, "0001", res)
|
assert.Equal(t, "0001", res)
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestProcessTreeFlatten(t *testing.T) {
|
func TestProcessTreeFlatten(t *testing.T) {
|
||||||
|
testPrepare()
|
||||||
bytes := []byte(`[
|
bytes := []byte(`[
|
||||||
{
|
{
|
||||||
"id": 1,
|
"id": 1,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue