elvish/eval/builtin_fn_fs_test.go
Qi Xiao 1c133f6979 util: Change the API of WithTempDir and InTempDir.
They have been renamed to TestDir and InTestDir, and instead of taking a
callback, they return a cleanup function. This saves one level of
indentation in the caller.
2018-10-13 14:04:13 +01:00

26 lines
472 B
Go

package eval
import (
"path/filepath"
"testing"
"github.com/elves/elvish/parse"
)
func TestBuiltinFnFS(t *testing.T) {
tmpHome, cleanup := InTempHome()
defer cleanup()
MustMkdirAll("dir", 0700)
MustCreateEmpty("file")
Test(t,
That(`path-base a/b/c.png`).Puts("c.png"),
That("tilde-abbr "+parse.Quote(filepath.Join(tmpHome, "foobar"))).
Puts(filepath.Join("~", "foobar")),
That(`-is-dir ~/dir`).Puts(true),
That(`-is-dir ~/file`).Puts(false),
)
}