示例#1
0
func TestRename(t *testing.T) {
	path := "c:/gowork/renExample"
	os.Remove(path)
	d := directory.New(path)
	err := d.Create()
	if err != nil {
		t.Fatal(err)
	}
	ex, err := exists(path)
	if err != nil {
		t.Fatal(err)
	}
	if !ex {
		t.Fatal("Not created.")
	}
	newname := "laliboy"
	err = d.Rename(newname)
	if err != nil {
		t.Fatal(err)
	}
	newpath := filepath.Join(filepath.Dir(path), newname)
	ex, err = exists(newpath)
	if err != nil {
		t.Fatal(err)
	}
	if !ex {
		t.Fatal("Rename didn't happen.")
	}
}
示例#2
0
文件: filesys.go 项目: Laller/nocrud
func (f *FileSys) SelectPlace(s string) (iface.Directory, error) {
	var path string
	switch s {
	case "template":
		path = scut.GetTPath(f.opt, f.host)
	case "modules":
		path = "modules"
	case "uploads":
		path = "uploads"
	default:
		return nil, fmt.Errorf("Can't find.")
	}
	path = filepath.Join(f.root, path)
	return directory.New(path), nil
}
示例#3
0
func TestCreate(t *testing.T) {
	path := "c:/gowork/renExample"
	os.Remove(path)
	d := directory.New(path)
	err := d.Create()
	if err != nil {
		t.Fatal(err)
	}
	ex, err := exists(path)
	if err != nil {
		t.Fatal(err)
	}
	if !ex {
		t.Fatal("Not created.")
	}
}