mirror of
https://gitee.com/johng/gf
synced 2026-06-07 10:22:11 +08:00
调整测试文件生成目录
This commit is contained in:
@ -11,19 +11,19 @@ import (
|
||||
|
||||
//创建测试文件
|
||||
func CreateTestFile(filename, content string) error {
|
||||
TempDir := os.TempDir()
|
||||
TempDir := Testpath()
|
||||
err := ioutil.WriteFile(TempDir+filename, []byte(content), 0666)
|
||||
return err
|
||||
}
|
||||
|
||||
//测试完删除文件或目录
|
||||
func DelTestFiles(filenames string) {
|
||||
os.RemoveAll(filenames)
|
||||
os.RemoveAll(Testpath()+filenames)
|
||||
}
|
||||
|
||||
//创建目录
|
||||
func CreateDir(paths string) {
|
||||
TempDir := os.TempDir()
|
||||
TempDir := Testpath()
|
||||
os.Mkdir(TempDir+paths, 0666)
|
||||
}
|
||||
|
||||
@ -44,6 +44,16 @@ func Formatpath(paths string) string {
|
||||
return paths
|
||||
}
|
||||
|
||||
//指定返回要测试的目录
|
||||
func Testpath() string {
|
||||
psths,err:= filepath.Abs("./")
|
||||
if err!=nil{
|
||||
return os.TempDir()
|
||||
}
|
||||
return psths
|
||||
|
||||
}
|
||||
|
||||
func TestGetContents(t *testing.T) {
|
||||
gtest.Case(t, func() {
|
||||
|
||||
@ -51,25 +61,26 @@ func TestGetContents(t *testing.T) {
|
||||
filepaths string = "/testfile_t1.txt"
|
||||
)
|
||||
CreateTestFile(filepaths, "my name is jroam")
|
||||
|
||||
gtest.Assert(GetContents(os.TempDir()+filepaths), "my name is jroam")
|
||||
gtest.Assert(GetContents(""), "")
|
||||
defer DelTestFiles(filepaths)
|
||||
|
||||
gtest.Assert(GetContents(Testpath()+filepaths), "my name is jroam")
|
||||
gtest.Assert(GetContents(""), "")
|
||||
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
func TestGetBinContents(t *testing.T) {
|
||||
gtest.Case(t, func() {
|
||||
var (
|
||||
filepaths1 string = "/testfile_t1.txt" //存在文件
|
||||
filepaths2 string = os.TempDir() + "/testfile_t1_no.txt" //不存大文件
|
||||
filepaths1 string = "/testfile_t1.txt" //存在文件
|
||||
filepaths2 string = Testpath() + "/testfile_t1_no.txt" //不存大文件
|
||||
readcontent []byte
|
||||
str1 string = "my name is jroam"
|
||||
)
|
||||
CreateTestFile(filepaths1, str1)
|
||||
defer DelTestFiles(filepaths1)
|
||||
readcontent = GetBinContents(os.TempDir() + filepaths1)
|
||||
readcontent = GetBinContents(Testpath() + filepaths1)
|
||||
gtest.Assert(readcontent, []byte(str1))
|
||||
|
||||
readcontent = GetBinContents(filepaths2)
|
||||
@ -92,7 +103,7 @@ func TestTruncate(t *testing.T) {
|
||||
)
|
||||
CreateTestFile(filepaths1, "abcdefghijkmln")
|
||||
defer DelTestFiles(filepaths1)
|
||||
err = Truncate(os.TempDir()+filepaths1, 200)
|
||||
err = Truncate(Testpath()+filepaths1, 200)
|
||||
gtest.Assert(err, nil)
|
||||
|
||||
err = Truncate("", 200)
|
||||
@ -111,11 +122,11 @@ func TestPutContents(t *testing.T) {
|
||||
CreateTestFile(filepaths, "a")
|
||||
defer DelTestFiles(filepaths)
|
||||
|
||||
err = PutContents(os.TempDir()+filepaths, "test!")
|
||||
err = PutContents(Testpath()+filepaths, "test!")
|
||||
gtest.Assert(err, nil)
|
||||
|
||||
//==================判断是否真正写入
|
||||
readcontent, err = ioutil.ReadFile(os.TempDir() + filepaths)
|
||||
readcontent, err = ioutil.ReadFile(Testpath() + filepaths)
|
||||
gtest.Assert(err, nil)
|
||||
gtest.Assert(string(readcontent), "test!")
|
||||
|
||||
@ -135,11 +146,11 @@ func TestPutContentsAppend(t *testing.T) {
|
||||
|
||||
CreateTestFile(filepaths, "a")
|
||||
defer DelTestFiles(filepaths)
|
||||
err = PutContentsAppend(os.TempDir()+filepaths, "hello")
|
||||
err = PutContentsAppend(Testpath()+filepaths, "hello")
|
||||
gtest.Assert(err, nil)
|
||||
|
||||
//==================判断是否真正写入
|
||||
readcontent, err = ioutil.ReadFile(os.TempDir() + filepaths)
|
||||
readcontent, err = ioutil.ReadFile(Testpath() + filepaths)
|
||||
gtest.Assert(err, nil)
|
||||
gtest.Assert(string(readcontent), "ahello")
|
||||
|
||||
@ -160,11 +171,11 @@ func TestPutBinContents(t *testing.T) {
|
||||
CreateTestFile(filepaths, "a")
|
||||
defer DelTestFiles(filepaths)
|
||||
|
||||
err = PutBinContents(os.TempDir()+filepaths, []byte("test!!"))
|
||||
err = PutBinContents(Testpath()+filepaths, []byte("test!!"))
|
||||
gtest.Assert(err, nil)
|
||||
|
||||
//==================判断是否真正写入
|
||||
readcontent, err = ioutil.ReadFile(os.TempDir() + filepaths)
|
||||
readcontent, err = ioutil.ReadFile(Testpath() + filepaths)
|
||||
gtest.Assert(err, nil)
|
||||
gtest.Assert(string(readcontent), "test!!")
|
||||
|
||||
@ -183,11 +194,11 @@ func TestPutBinContentsAppend(t *testing.T) {
|
||||
)
|
||||
CreateTestFile(filepaths, "test!!")
|
||||
defer DelTestFiles(filepaths)
|
||||
err = PutBinContentsAppend(os.TempDir()+filepaths, []byte("word"))
|
||||
err = PutBinContentsAppend(Testpath()+filepaths, []byte("word"))
|
||||
gtest.Assert(err, nil)
|
||||
|
||||
//==================判断是否真正写入
|
||||
readcontent, err = ioutil.ReadFile(os.TempDir() + filepaths)
|
||||
readcontent, err = ioutil.ReadFile(Testpath() + filepaths)
|
||||
gtest.Assert(err, nil)
|
||||
gtest.Assert(string(readcontent), "test!!word")
|
||||
|
||||
@ -206,7 +217,7 @@ func TestGetBinContentsByTwoOffsetsByPath(t *testing.T) {
|
||||
|
||||
CreateTestFile(filepaths, "abcdefghijk")
|
||||
defer DelTestFiles(filepaths)
|
||||
readcontent = GetBinContentsByTwoOffsetsByPath(os.TempDir()+filepaths, 2, 5)
|
||||
readcontent = GetBinContentsByTwoOffsetsByPath(Testpath()+filepaths, 2, 5)
|
||||
|
||||
gtest.Assert(string(readcontent), "cde")
|
||||
|
||||
@ -225,7 +236,7 @@ func TestGetNextCharOffsetByPath(t *testing.T) {
|
||||
)
|
||||
CreateTestFile(filepaths, "abcdefghijk")
|
||||
defer DelTestFiles(filepaths)
|
||||
localindex = GetNextCharOffsetByPath(os.TempDir()+filepaths, 'd', 1)
|
||||
localindex = GetNextCharOffsetByPath(Testpath()+filepaths, 'd', 1)
|
||||
gtest.Assert(localindex, 3)
|
||||
|
||||
localindex = GetNextCharOffsetByPath("", 'd', 1)
|
||||
@ -294,13 +305,13 @@ func TestGetBinContentsTilCharByPath(t *testing.T) {
|
||||
CreateTestFile(filepaths, "abcdefghijklmn")
|
||||
defer DelTestFiles(filepaths)
|
||||
|
||||
reads, _ = GetBinContentsTilCharByPath(os.TempDir()+filepaths, 'c', 2)
|
||||
reads, _ = GetBinContentsTilCharByPath(Testpath()+filepaths, 'c', 2)
|
||||
gtest.Assert(string(reads), "c")
|
||||
|
||||
reads, _ = GetBinContentsTilCharByPath(os.TempDir()+filepaths, 'y', 1)
|
||||
reads, _ = GetBinContentsTilCharByPath(Testpath()+filepaths, 'y', 1)
|
||||
gtest.Assert(string(reads), "")
|
||||
|
||||
_, indexs = GetBinContentsTilCharByPath(os.TempDir()+filepaths, 'x', 1)
|
||||
_, indexs = GetBinContentsTilCharByPath(Testpath()+filepaths, 'x', 1)
|
||||
gtest.Assert(indexs, -1)
|
||||
|
||||
})
|
||||
|
||||
@ -2,7 +2,6 @@ package gfile
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/g/test/gtest"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
@ -21,18 +20,18 @@ func TestSearch(t *testing.T) {
|
||||
CreateDir(paths1)
|
||||
defer DelTestFiles(paths1)
|
||||
|
||||
tpath, err = Search(os.TempDir() + paths1)
|
||||
tpath, err = Search(Testpath() + paths1)
|
||||
gtest.Assert(err, nil)
|
||||
|
||||
tpath = filepath.ToSlash(tpath)
|
||||
|
||||
//==================自定义优先路径
|
||||
tpath2, err = Search(os.TempDir() + paths1)
|
||||
tpath2, err = Search(Testpath() + paths1)
|
||||
gtest.Assert(err, nil)
|
||||
tpath2 = filepath.ToSlash(tpath2)
|
||||
|
||||
//tempstr, _ = filepath.Abs("./")
|
||||
tempstr = os.TempDir()
|
||||
tempstr = Testpath()
|
||||
paths1 = tempstr + paths1
|
||||
paths1 = filepath.ToSlash(paths1)
|
||||
//paths1 = strings.Replace(paths1, "./", "/", 1)
|
||||
@ -42,13 +41,13 @@ func TestSearch(t *testing.T) {
|
||||
gtest.Assert(tpath2, tpath)
|
||||
|
||||
//测试当前目录
|
||||
tpath2, err = Search(os.TempDir()+paths1, "./")
|
||||
tpath2, err = Search(Testpath()+paths1, "./")
|
||||
gtest.Assert(err, nil)
|
||||
tpath2 = filepath.ToSlash(tpath2)
|
||||
|
||||
//测试当前目录
|
||||
tempstr, _ = filepath.Abs("./")
|
||||
tempstr = os.TempDir()
|
||||
tempstr = Testpath()
|
||||
paths1 = tempstr + paths1
|
||||
paths1 = filepath.ToSlash(paths1)
|
||||
|
||||
|
||||
@ -4,7 +4,6 @@ package gfile
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/g/test/gtest"
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@ -18,7 +17,7 @@ func TestSize(t *testing.T) {
|
||||
CreateTestFile(paths1, "abcdefghijklmn")
|
||||
defer DelTestFiles(paths1)
|
||||
|
||||
sizes = Size(os.TempDir() + paths1)
|
||||
sizes = Size(Testpath() + paths1)
|
||||
gtest.Assert(sizes, 14)
|
||||
|
||||
sizes = Size("")
|
||||
@ -54,7 +53,7 @@ func TestReadableSize(t *testing.T) {
|
||||
)
|
||||
CreateTestFile(paths1, "abcdefghijklmn")
|
||||
defer DelTestFiles(paths1)
|
||||
gtest.Assert(ReadableSize(os.TempDir()+paths1), "14.00B")
|
||||
gtest.Assert(ReadableSize(Testpath()+paths1), "14.00B")
|
||||
gtest.Assert(ReadableSize(""), "0.00B")
|
||||
|
||||
})
|
||||
|
||||
@ -15,7 +15,7 @@ func TestIsDir(t *testing.T) {
|
||||
CreateDir(paths)
|
||||
defer DelTestFiles(paths)
|
||||
|
||||
gtest.Assert(IsDir(os.TempDir()+paths), true)
|
||||
gtest.Assert(IsDir(Testpath()+paths), true)
|
||||
gtest.Assert(IsDir("./testfile2"), false)
|
||||
gtest.Assert(IsDir("./testfile/tt.txt"), false)
|
||||
gtest.Assert(IsDir(""), false)
|
||||
@ -32,11 +32,11 @@ func TestCreate(t *testing.T) {
|
||||
fileobj *os.File
|
||||
)
|
||||
|
||||
filepaths = append(filepaths, os.TempDir()+"/testfile_cc1.txt")
|
||||
filepaths = append(filepaths, os.TempDir()+"/testfile_cc2.txt")
|
||||
filepaths = append(filepaths, "/testfile_cc1.txt")
|
||||
filepaths = append(filepaths, "/testfile_cc2.txt")
|
||||
|
||||
for _, v := range filepaths {
|
||||
fileobj, err = Create(v)
|
||||
fileobj, err = Create(Testpath()+v)
|
||||
defer DelTestFiles(v)
|
||||
fileobj.Close()
|
||||
gtest.Assert(err, nil)
|
||||
@ -67,7 +67,7 @@ func TestOpen(t *testing.T) {
|
||||
flags = append(flags, false)
|
||||
|
||||
for k, v := range files {
|
||||
fileobj, err = Open(os.TempDir() + v)
|
||||
fileobj, err = Open(Testpath() + v)
|
||||
fileobj.Close()
|
||||
if flags[k] {
|
||||
gtest.Assert(err, nil)
|
||||
@ -100,7 +100,7 @@ func TestOpenFile(t *testing.T) {
|
||||
flags = append(flags, true)
|
||||
|
||||
for k, v := range files {
|
||||
fileobj, err = OpenFile(os.TempDir()+v, os.O_RDWR, 0666)
|
||||
fileobj, err = OpenFile(Testpath()+v, os.O_RDWR, 0666)
|
||||
fileobj.Close()
|
||||
if flags[k] {
|
||||
gtest.Assert(err, nil)
|
||||
@ -131,7 +131,7 @@ func TestOpenWithFlag(t *testing.T) {
|
||||
flags = append(flags, false)
|
||||
|
||||
for k, v := range files {
|
||||
fileobj, err = OpenWithFlag(os.TempDir()+v, os.O_RDWR)
|
||||
fileobj, err = OpenWithFlag(Testpath()+v, os.O_RDWR)
|
||||
fileobj.Close()
|
||||
if flags[k] {
|
||||
gtest.Assert(err, nil)
|
||||
@ -162,7 +162,7 @@ func TestOpenWithFlagPerm(t *testing.T) {
|
||||
flags = append(flags, false)
|
||||
|
||||
for k, v := range files {
|
||||
fileobj, err = OpenWithFlagPerm(os.TempDir()+v, os.O_RDWR, 666)
|
||||
fileobj, err = OpenWithFlagPerm(Testpath()+v, os.O_RDWR, 666)
|
||||
fileobj.Close()
|
||||
if flags[k] {
|
||||
gtest.Assert(err, nil)
|
||||
@ -195,7 +195,7 @@ func TestExists(t *testing.T) {
|
||||
flags = append(flags, false)
|
||||
|
||||
for k, v := range files {
|
||||
flag = Exists(os.TempDir() + v)
|
||||
flag = Exists(Testpath() + v)
|
||||
if flags[k] {
|
||||
gtest.Assert(flag, true)
|
||||
} else {
|
||||
@ -240,7 +240,7 @@ func TestIsFile(t *testing.T) {
|
||||
flags = append(flags, false)
|
||||
|
||||
for k, v := range files {
|
||||
flag = IsFile(os.TempDir() + v)
|
||||
flag = IsFile(Testpath() + v)
|
||||
if flags[k] {
|
||||
gtest.Assert(flag, true)
|
||||
} else {
|
||||
@ -263,10 +263,10 @@ func TestInfo(t *testing.T) {
|
||||
|
||||
CreateTestFile(paths, "")
|
||||
defer DelTestFiles(paths)
|
||||
files, err = Info(os.TempDir() + paths)
|
||||
files, err = Info(Testpath() + paths)
|
||||
gtest.Assert(err, nil)
|
||||
|
||||
files2, err = os.Stat(os.TempDir() + paths)
|
||||
files2, err = os.Stat(Testpath() + paths)
|
||||
gtest.Assert(err, nil)
|
||||
|
||||
gtest.Assert(files, files2)
|
||||
@ -310,16 +310,16 @@ func TestCopy(t *testing.T) {
|
||||
gtest.Case(t, func() {
|
||||
var (
|
||||
paths string = "/testfile_copyfile1.txt"
|
||||
topath string = os.TempDir() + "/testfile_copyfile2.txt"
|
||||
topath string = "/testfile_copyfile2.txt"
|
||||
)
|
||||
|
||||
CreateTestFile(paths, "")
|
||||
defer DelTestFiles(paths)
|
||||
|
||||
gtest.Assert(Copy(os.TempDir()+paths, topath), nil)
|
||||
gtest.Assert(Copy(Testpath()+paths, Testpath()+topath), nil)
|
||||
defer DelTestFiles(topath)
|
||||
|
||||
gtest.Assert(IsFile(topath), true)
|
||||
gtest.Assert(IsFile(Testpath()+topath), true)
|
||||
|
||||
gtest.AssertNE(Copy("", ""), nil)
|
||||
|
||||
@ -345,7 +345,7 @@ func TestDirNames(t *testing.T) {
|
||||
}
|
||||
defer DelTestFiles(paths)
|
||||
|
||||
readlist, err = DirNames(os.TempDir() + paths)
|
||||
readlist, err = DirNames(Testpath() + paths)
|
||||
|
||||
gtest.Assert(err, nil)
|
||||
gtest.Assert(havelist, readlist)
|
||||
@ -371,8 +371,8 @@ func TestGlob(t *testing.T) {
|
||||
}
|
||||
|
||||
havelist2 := []string{
|
||||
os.TempDir() + "/testfiles/t1.txt",
|
||||
os.TempDir() + "/testfiles/t2.txt",
|
||||
Testpath() + "/testfiles/t1.txt",
|
||||
Testpath() + "/testfiles/t2.txt",
|
||||
}
|
||||
|
||||
//===============================构建测试文件
|
||||
@ -382,11 +382,11 @@ func TestGlob(t *testing.T) {
|
||||
}
|
||||
defer DelTestFiles(dirpath)
|
||||
|
||||
resultlist, err = Glob(os.TempDir()+paths, true)
|
||||
resultlist, err = Glob(Testpath()+paths, true)
|
||||
gtest.Assert(err, nil)
|
||||
gtest.Assert(resultlist, havelist1)
|
||||
|
||||
resultlist, err = Glob(os.TempDir()+paths, false)
|
||||
resultlist, err = Glob(Testpath()+paths, false)
|
||||
|
||||
gtest.Assert(err, nil)
|
||||
gtest.Assert(Formatpaths(resultlist), Formatpaths(havelist2))
|
||||
@ -403,7 +403,7 @@ func TestRemove(t *testing.T) {
|
||||
paths string = "/testfile_t1.txt"
|
||||
)
|
||||
CreateTestFile(paths, "")
|
||||
gtest.Assert(Remove(os.TempDir()+paths), nil)
|
||||
gtest.Assert(Remove(Testpath()+paths), nil)
|
||||
|
||||
gtest.Assert(Remove(""), nil)
|
||||
|
||||
@ -422,7 +422,7 @@ func TestIsReadable(t *testing.T) {
|
||||
CreateTestFile(paths1, "")
|
||||
defer DelTestFiles(paths1)
|
||||
|
||||
gtest.Assert(IsReadable(os.TempDir()+paths1), true)
|
||||
gtest.Assert(IsReadable(Testpath()+paths1), true)
|
||||
gtest.Assert(IsReadable(paths2), false)
|
||||
|
||||
})
|
||||
@ -437,7 +437,7 @@ func TestIsWritable(t *testing.T) {
|
||||
|
||||
CreateTestFile(paths1, "")
|
||||
defer DelTestFiles(paths1)
|
||||
gtest.Assert(IsWritable(os.TempDir()+paths1), true)
|
||||
gtest.Assert(IsWritable(Testpath()+paths1), true)
|
||||
gtest.Assert(IsWritable(paths2), false)
|
||||
|
||||
})
|
||||
@ -452,7 +452,7 @@ func TestChmod(t *testing.T) {
|
||||
CreateTestFile(paths1, "")
|
||||
defer DelTestFiles(paths1)
|
||||
|
||||
gtest.Assert(Chmod(os.TempDir()+paths1, 0777), nil)
|
||||
gtest.Assert(Chmod(Testpath()+paths1, 0777), nil)
|
||||
gtest.AssertNE(Chmod(paths2, 0777), nil)
|
||||
|
||||
})
|
||||
@ -471,11 +471,11 @@ func TestScanDir(t *testing.T) {
|
||||
CreateTestFile(paths1+"/t2.txt", "")
|
||||
defer DelTestFiles(paths1)
|
||||
|
||||
files, err = ScanDir(os.TempDir()+paths1, "t*")
|
||||
files, err = ScanDir(Testpath()+paths1, "t*")
|
||||
|
||||
result := []string{
|
||||
os.TempDir() + paths1 + "/t1.txt",
|
||||
os.TempDir() + paths1 + "/t2.txt",
|
||||
Testpath() + paths1 + "/t1.txt",
|
||||
Testpath() + paths1 + "/t2.txt",
|
||||
}
|
||||
|
||||
gtest.Assert(err, nil)
|
||||
@ -564,7 +564,7 @@ func TestBasename(t *testing.T) {
|
||||
CreateTestFile(paths1, "")
|
||||
defer DelTestFiles(paths1)
|
||||
|
||||
readlPath = Basename(os.TempDir() + paths1)
|
||||
readlPath = Basename(Testpath() + paths1)
|
||||
gtest.Assert(readlPath, "testfilerr_GetContents.txt")
|
||||
|
||||
})
|
||||
@ -579,9 +579,9 @@ func TestDir(t *testing.T) {
|
||||
CreateDir(paths1)
|
||||
defer DelTestFiles(paths1)
|
||||
|
||||
readlPath = Dir(os.TempDir() + paths1)
|
||||
readlPath = Dir(Testpath() + paths1)
|
||||
|
||||
gtest.Assert(readlPath, os.TempDir())
|
||||
gtest.Assert(readlPath, Testpath())
|
||||
|
||||
})
|
||||
}
|
||||
@ -599,8 +599,8 @@ func TestExt(t *testing.T) {
|
||||
CreateDir(dirpath1)
|
||||
defer DelTestFiles(dirpath1)
|
||||
|
||||
gtest.Assert(Ext(os.TempDir()+paths1), ".txt")
|
||||
gtest.Assert(Ext(os.TempDir()+dirpath1), "")
|
||||
gtest.Assert(Ext(Testpath()+paths1), ".txt")
|
||||
gtest.Assert(Ext(Testpath()+dirpath1), "")
|
||||
|
||||
})
|
||||
}
|
||||
@ -626,13 +626,13 @@ func TestMkdir(t *testing.T) {
|
||||
|
||||
defer DelTestFiles(tpath)
|
||||
|
||||
err = Mkdir(os.TempDir() + tpath)
|
||||
err = Mkdir(Testpath() + tpath)
|
||||
gtest.Assert(err, nil)
|
||||
|
||||
err = Mkdir("")
|
||||
gtest.AssertNE(err, nil)
|
||||
|
||||
err = Mkdir(os.TempDir() + tpath + "2/t1")
|
||||
err = Mkdir(Testpath() + tpath + "2/t1")
|
||||
gtest.Assert(err, nil)
|
||||
|
||||
})
|
||||
@ -649,7 +649,7 @@ func TestStat(t *testing.T) {
|
||||
CreateTestFile(tpath1, "")
|
||||
defer DelTestFiles(tpath1)
|
||||
|
||||
_, err = Stat(os.TempDir() + tpath1)
|
||||
_, err = Stat(Testpath() + tpath1)
|
||||
gtest.Assert(err, nil)
|
||||
|
||||
_, err = Stat(tpath2)
|
||||
|
||||
@ -18,10 +18,10 @@ func TestMTime(t *testing.T) {
|
||||
|
||||
CreateTestFile(file1, "")
|
||||
defer DelTestFiles(file1)
|
||||
fileobj, err = os.Stat(os.TempDir() + file1)
|
||||
fileobj, err = os.Stat(Testpath() + file1)
|
||||
gtest.Assert(err, nil)
|
||||
|
||||
gtest.Assert(MTime(os.TempDir()+file1), fileobj.ModTime().Unix())
|
||||
gtest.Assert(MTime(Testpath()+file1), fileobj.ModTime().Unix())
|
||||
gtest.Assert(MTime(""), 0)
|
||||
})
|
||||
}
|
||||
@ -36,10 +36,10 @@ func TestMTimeMillisecond(t *testing.T) {
|
||||
|
||||
CreateTestFile(file1, "")
|
||||
defer DelTestFiles(file1)
|
||||
fileobj, err = os.Stat(os.TempDir() + file1)
|
||||
fileobj, err = os.Stat(Testpath() + file1)
|
||||
gtest.Assert(err, nil)
|
||||
|
||||
gtest.AssertGTE(MTimeMillisecond(os.TempDir()+file1), fileobj.ModTime().Nanosecond()/1000000)
|
||||
gtest.AssertGTE(MTimeMillisecond(Testpath()+file1), fileobj.ModTime().Nanosecond()/1000000)
|
||||
gtest.Assert(MTimeMillisecond(""), 0)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user