From 84ed3d5767af717e8bebc0bae59ad07c5f60fc6b Mon Sep 17 00:00:00 2001 From: "yybjroam@qq.com" Date: Mon, 15 Apr 2019 23:14:48 +0800 Subject: [PATCH] add move and rename testfun --- g/os/gfile/gfile_test.go | 77 ++++++++++++++++++++++++---------------- 1 file changed, 46 insertions(+), 31 deletions(-) diff --git a/g/os/gfile/gfile_test.go b/g/os/gfile/gfile_test.go index 8316c7926..2e36ab088 100644 --- a/g/os/gfile/gfile_test.go +++ b/g/os/gfile/gfile_test.go @@ -275,37 +275,52 @@ func TestInfo(t *testing.T) { }) } -//func TestMove(t *testing.T) { -// gtest.Case(t, func(){ -// var( -// paths string ="./testfile/havefile1/ttn1.txt" -// topath string ="./testfile/havefile1/ttn2.txt" -// ) -// -// gtest.Assert(Move(paths,topath),nil) -// -// }) -//} -// -// func TestRename(t *testing.T){ -// gtest.Case(t, func(){ -// var( -// -// paths string ="./testfile/havefile1/ttm1.txt" -// topath string ="./testfile/havefile1/ttm2.txt" -// -// ) -// -// gtest.Assert(Rename(paths,topath),nil) -// gtest.Assert(IsFile(topath),true) -// -// gtest.AssertNE(Rename("",""),nil) -// -// -// }) -// -// -// } +func TestMove(t *testing.T) { + gtest.Case(t, func() { + var ( + paths string = "/ovetest" + filepaths string = "/testfile_ttn1.txt" + topath string = "/testfile_ttn2.txt" + ) + CreateDir("/ovetest") + CreateTestFile(paths+filepaths, "a") + + defer DelTestFiles(paths) + + yfile := Testpath() + paths + filepaths + tofile := Testpath() + paths + topath + + gtest.Assert(Move(yfile, tofile), nil) + + //检查移动后的文件是否真实存在 + _, err := os.Stat(tofile) + gtest.Assert(os.IsNotExist(err), false) + + }) +} + +func TestRename(t *testing.T) { + gtest.Case(t, func() { + var ( + paths string = "/testfiles" + ypath string = "/testfilettm1.txt" + topath string = "/testfilettm2.txt" + ) + CreateDir(paths) + CreateTestFile(paths+ypath, "a") + defer DelTestFiles(paths) + + ypath = Testpath() + paths + ypath + topath = Testpath() + paths + topath + + gtest.Assert(Rename(ypath, topath), nil) + gtest.Assert(IsFile(topath), true) + + gtest.AssertNE(Rename("", ""), nil) + + }) + +} func TestCopy(t *testing.T) { gtest.Case(t, func() {