Merge pull request #380 from trheyi/main

[fix] tests
This commit is contained in:
Max 2023-04-25 10:05:00 +08:00 committed by GitHub
commit 117811df55
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 2 deletions

View file

@ -191,6 +191,7 @@ jobs:
echo ".:\n" && ls -l .
echo "..:\n" && ls -l ..
echo "../app:\n" && ls -l ../app
ping -c 1 -t 1 local.iqka.com
- name: Test Prepare
@ -199,6 +200,12 @@ jobs:
make fmt-check
make misspell-check
- name: Inspect
run: |
go run . run utils.env.Get MONGO_TEST_HOST
go run . run utils.env.Get REDIS_TEST_HOST
go run . inspect
- name: Run test
run: |
make test

View file

@ -1,10 +1,12 @@
package connector
import (
"os"
"testing"
"github.com/stretchr/testify/assert"
"github.com/yaoapp/gou/connector"
"github.com/yaoapp/kun/utils"
"github.com/yaoapp/yao/config"
"github.com/yaoapp/yao/test"
)
@ -13,7 +15,26 @@ func TestLoad(t *testing.T) {
test.Prepare(t, config.Conf)
defer test.Clean()
Load(config.Conf)
err := Load(config.Conf)
utils.Dump(config.Conf, "ERROR---", err, "-- END ERROR---")
utils.Dump(
"REDIS---",
os.Getenv("REDIS_TEST_HOST"),
os.Getenv("REDIS_TEST_PORT"),
os.Getenv("REDIS_TEST_USER"),
os.Getenv("REDIS_TEST_PASS"),
"-- END REDIS---",
)
utils.Dump(
"SQLITE---",
os.Getenv("SQLITE_DB"),
"-- END SQLITE---",
)
if err != nil {
t.Fatal(err)
}
check(t)
}
@ -22,6 +43,9 @@ func check(t *testing.T) {
for id := range connector.Connectors {
ids[id] = true
}
utils.Dump(ids)
assert.True(t, ids["mongo"])
assert.True(t, ids["mysql"])
assert.True(t, ids["redis"])

View file

@ -98,7 +98,7 @@ func TestAPI(t *testing.T) {
code, rows = httpGet[arr]("/dsl/ReadDir?name=/models&recursive=1", t)
assert.Equal(t, 200, code)
assert.Equal(t, 12, len(rows))
assert.Equal(t, 13, len(rows))
code, length := httpPost[int]("/dsl/WriteFile?name=/models/foo.mod.yao", []byte(`{"name":"foo"}`), t)
assert.Equal(t, 200, code)