os: implement os.Symlink and os.Readlink

This commit is contained in:
Dan Kegel
2022-01-15 20:56:31 -08:00
committed by Ron Evans
parent db0efc52c7
commit 57b8f7e667
6 changed files with 183 additions and 11 deletions
+22
View File
@@ -96,6 +96,28 @@ func TestRemove(t *testing.T) {
}
}
// chtmpdir changes the working directory to a new temporary directory and
// provides a cleanup function.
func chtmpdir(t *testing.T) func() {
oldwd, err := Getwd()
if err != nil {
t.Fatalf("chtmpdir: %v", err)
}
d, err := MkdirTemp("", "test")
if err != nil {
t.Fatalf("chtmpdir: %v", err)
}
if err := Chdir(d); err != nil {
t.Fatalf("chtmpdir: %v", err)
}
return func() {
if err := Chdir(oldwd); err != nil {
t.Fatalf("chtmpdir: %v", err)
}
RemoveAll(d)
}
}
func TestRename(t *testing.T) {
// TODO: use t.TempDir()
from, to := TempDir()+"/"+"TestRename-from", TempDir()+"/"+"TestRename-to"