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.") } }
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 }
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.") } }