Files
fs/fs_test.go
T

32 lines
542 B
Go
Raw Normal View History

2015-08-09 16:20:47 -07:00
package fs
import (
"io/ioutil"
"os"
"path/filepath"
"testing"
)
func TestExists(t *testing.T) {
tmp, err := ioutil.TempDir("", "fs-test-")
if err != nil {
panic(err)
}
filename := filepath.Join(tmp, "foo")
if Exists(filename) {
t.Errorf("shouldn't have been able to find non-existant file: %s", filename)
}
f, err := os.Create(filename)
if err != nil {
t.Errorf("problem opening fresh file (%q): %v", filename, err)
}
f.Close()
if !Exists(filename) {
t.Errorf("failure to find existant file: %s", filename)
}
}