29 lines
641 B
Go
29 lines
641 B
Go
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)
|
|
}
|