This commit is contained in:
sm
2015-08-09 16:20:47 -07:00
commit d65b52fedb
4 changed files with 72 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
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)
}
}