32 lines
542 B
Go
32 lines
542 B
Go
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)
|
|
}
|
|
}
|