mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-13 18:07:51 +08:00
28 lines
541 B
Go
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)
|
|
}
|
|
}
|