elvish/util/path_test.go
2014-09-28 11:09:31 +08:00

28 lines
541 B
Go

package util
import (
"io/ioutil"
"os"
"path/filepath"
"testing"
)
func TestGetwd(t *testing.T) {
dir, error := ioutil.TempDir("", "elvishtest.")
if error != nil {
t.Errorf("Got error when creating temp dir: %v", error)
} else {
os.Chdir(dir)
dir, error = filepath.EvalSymlinks(dir)
if gotwd := Getwd(); gotwd != dir || error != nil {
t.Errorf("Getwd() -> %v, want %v", gotwd, dir)
}
os.Remove(dir)
}
os.Chdir(os.Getenv("HOME"))
if gotwd := Getwd(); gotwd != "~" {
t.Errorf("Getwd() -> %v, want ~", gotwd)
}
}