This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package langext
|
||||
|
||||
import (
|
||||
"git.blackforestbytes.com/BlackForestBytes/goext/tst"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestFileExistsTrue(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
path := filepath.Join(dir, "f.txt")
|
||||
if err := os.WriteFile(path, []byte("hi"), 0o644); err != nil {
|
||||
t.Fatalf("setup failed: %v", err)
|
||||
}
|
||||
tst.AssertEqual(t, FileExists(path), true)
|
||||
}
|
||||
|
||||
func TestFileExistsFalse(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
path := filepath.Join(dir, "missing.txt")
|
||||
tst.AssertEqual(t, FileExists(path), false)
|
||||
}
|
||||
|
||||
func TestFileExistsDirectoryReturnsFalse(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
tst.AssertEqual(t, FileExists(dir), false)
|
||||
}
|
||||
Reference in New Issue
Block a user