improve function gdebug.TestDataPath and update all usage codes

This commit is contained in:
John
2020-03-21 19:41:05 +08:00
parent 16958413bb
commit c2966817ce
14 changed files with 42 additions and 42 deletions

View File

@ -67,7 +67,7 @@ func Test_Basic(t *testing.T) {
}
func Test_File(t *testing.T) {
path := gfile.Join(gdebug.TestDataPath(), "test")
path := gdebug.TestDataPath("test")
expect := "dGVzdA=="
gtest.C(t, func(t *gtest.T) {
b, err := gbase64.EncodeFile(path)

View File

@ -43,7 +43,7 @@ func Test_Gzip_UnGzip(t *testing.T) {
}
func Test_Gzip_UnGzip_File(t *testing.T) {
srcPath := gfile.Join(gdebug.TestDataPath(), "gzip", "file.txt")
srcPath := gdebug.TestDataPath("gzip", "file.txt")
dstPath1 := gfile.Join(gfile.TempDir(), gtime.TimestampNanoStr(), "gzip.zip")
dstPath2 := gfile.Join(gfile.TempDir(), gtime.TimestampNanoStr(), "file.txt")

View File

@ -20,8 +20,8 @@ import (
func Test_ZipPath(t *testing.T) {
// file
gtest.C(t, func(t *gtest.T) {
srcPath := gfile.Join(gdebug.TestDataPath(), "zip", "path1", "1.txt")
dstPath := gfile.Join(gdebug.TestDataPath(), "zip", "zip.zip")
srcPath := gdebug.TestDataPath("zip", "path1", "1.txt")
dstPath := gdebug.TestDataPath("zip", "zip.zip")
t.Assert(gfile.Exists(dstPath), false)
err := gcompress.ZipPath(srcPath, dstPath)
@ -44,8 +44,8 @@ func Test_ZipPath(t *testing.T) {
})
// directory
gtest.C(t, func(t *gtest.T) {
srcPath := gfile.Join(gdebug.TestDataPath(), "zip")
dstPath := gfile.Join(gdebug.TestDataPath(), "zip", "zip.zip")
srcPath := gdebug.TestDataPath("zip")
dstPath := gdebug.TestDataPath("zip", "zip.zip")
pwd := gfile.Pwd()
err := gfile.Chdir(srcPath)
@ -77,10 +77,10 @@ func Test_ZipPath(t *testing.T) {
})
// multiple paths joined using char ','
gtest.C(t, func(t *gtest.T) {
srcPath := gfile.Join(gdebug.TestDataPath(), "zip")
srcPath1 := gfile.Join(gdebug.TestDataPath(), "zip", "path1")
srcPath2 := gfile.Join(gdebug.TestDataPath(), "zip", "path2")
dstPath := gfile.Join(gdebug.TestDataPath(), "zip", "zip.zip")
srcPath := gdebug.TestDataPath("zip")
srcPath1 := gdebug.TestDataPath("zip", "path1")
srcPath2 := gdebug.TestDataPath("zip", "path2")
dstPath := gdebug.TestDataPath("zip", "zip.zip")
pwd := gfile.Pwd()
err := gfile.Chdir(srcPath)
@ -116,9 +116,9 @@ func Test_ZipPath(t *testing.T) {
func Test_ZipPathWriter(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
srcPath := gfile.Join(gdebug.TestDataPath(), "zip")
srcPath1 := gfile.Join(gdebug.TestDataPath(), "zip", "path1")
srcPath2 := gfile.Join(gdebug.TestDataPath(), "zip", "path2")
srcPath := gdebug.TestDataPath("zip")
srcPath1 := gdebug.TestDataPath("zip", "path1")
srcPath2 := gdebug.TestDataPath("zip", "path2")
pwd := gfile.Pwd()
err := gfile.Chdir(srcPath)

View File

@ -14,14 +14,14 @@ import (
)
func Example_LoadJson() {
jsonFilePath := gfile.Join(gdebug.TestDataPath(), "json", "data1.json")
jsonFilePath := gdebug.TestDataPath("json", "data1.json")
j, _ := gjson.Load(jsonFilePath)
fmt.Println(j.Get("name"))
fmt.Println(j.Get("score"))
}
func Example_LoadXml() {
jsonFilePath := gfile.Join(gdebug.TestDataPath(), "xml", "data1.xml")
jsonFilePath := gdebug.TestDataPath("xml", "data1.xml")
j, _ := gjson.Load(jsonFilePath)
fmt.Println(j.Get("doc.name"))
fmt.Println(j.Get("doc.score"))