-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathutilities_test.go
52 lines (38 loc) · 1022 Bytes
/
utilities_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package main
import (
"runtime"
"testing"
"github.com/stretchr/testify/assert"
)
func TestFileExists(t *testing.T) {
actual := fileExists("README.md")
assert.True(t, actual, "Checks if file exists")
}
func TestFileExistsAcceptsSubDirectories(t *testing.T) {
actual := fileExists(".vscode/launch.json")
assert.True(t, actual, "Accepts Subdirectories")
}
func TestFileExistsNotExist(t *testing.T) {
actual := fileExists("NOT_EXIST")
assert.False(t, actual, "Returns false")
}
func TestFileExistsIgnoresDirectories(t *testing.T) {
actual := fileExists(".vscode")
assert.False(t, actual, "Ignores Directories")
}
func TestFileExistsThrowsError(t *testing.T) {
notDir := "LICENSE/NOT_EXIST"
var actual bool
if runtime.GOOS != "windows" {
defer func() {
if err := recover(); err != nil {
actual = true
}
assert.True(t, actual, "Throws Error")
}()
}
actualWindows := fileExists(notDir)
if runtime.GOOS == "windows" {
assert.False(t, actualWindows, "Doesn't throw an Error")
}
}