update unit test cases for gfile
@@ -8,7 +8,7 @@ import (
"github.com/gogf/gf/g/test/gtest"
)
-func Test_Scan(t *testing.T) {
+func Test_ScanDir(t *testing.T) {
teatPath := gfile.Dir(gfile.SourcePath()) + gfile.Separator + "testdata"
gtest.Case(t, func() {
files, err := gfile.ScanDir(teatPath, "*", false)
@@ -20,8 +20,25 @@ func Test_Scan(t *testing.T) {
gtest.Case(t, func() {
files, err := gfile.ScanDir(teatPath, "*", true)
gtest.Assert(err, nil)
- gtest.AssertNE(teatPath+gfile.Separator+"dir1", files)
- gtest.AssertNE(teatPath+gfile.Separator+"dir2", files)
+ gtest.AssertIN(teatPath+gfile.Separator+"dir1", files)
+ gtest.AssertIN(teatPath+gfile.Separator+"dir2", files)
+ gtest.AssertIN(teatPath+gfile.Separator+"dir1"+gfile.Separator+"file1", files)
+ gtest.AssertIN(teatPath+gfile.Separator+"dir2"+gfile.Separator+"file2", files)
+ })
+}
+
+func Test_ScanDirFile(t *testing.T) {
+ teatPath := gfile.Dir(gfile.SourcePath()) + gfile.Separator + "testdata"
+ gtest.Case(t, func() {
+ files, err := gfile.ScanDirFile(teatPath, "*", false)
+ gtest.Assert(err, nil)
+ gtest.Assert(len(files), 0)
+ })
+ gtest.Case(t, func() {
+ files, err := gfile.ScanDirFile(teatPath, "*", true)
+ gtest.Assert(err, nil)
+ gtest.AssertNI(teatPath+gfile.Separator+"dir1", files)
+ gtest.AssertNI(teatPath+gfile.Separator+"dir2", files)
gtest.AssertIN(teatPath+gfile.Separator+"dir1"+gfile.Separator+"file1", files)
gtest.AssertIN(teatPath+gfile.Separator+"dir2"+gfile.Separator+"file2", files)
})
