-
Notifications
You must be signed in to change notification settings - Fork 0
/
validator_test.go
29 lines (26 loc) · 937 Bytes
/
validator_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
package pathutils_test
import (
. "github.com/koofr/go-pathutils"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
var _ = Describe("Validator", func() {
It("should chech if path is valid", func() {
Expect(IsPathValid("file.txt")).To(BeTrue())
Expect(IsPathValid("/file.txt")).To(BeTrue())
Expect(IsPathValid("/path\\tofile.txt")).To(BeFalse())
Expect(IsPathValid("/path/.")).To(BeFalse())
Expect(IsPathValid("/path/..")).To(BeFalse())
Expect(IsPathValid("/path/../../../etc/passwd")).To(BeFalse())
Expect(IsPathValid("..")).To(BeFalse())
Expect(IsPathValid(".")).To(BeFalse())
})
It("should chech if name is valid", func() {
Expect(IsNameValid("file.txt")).To(BeTrue())
Expect(IsNameValid("/file.txt")).To(BeFalse())
Expect(IsNameValid("fil\\e.txt")).To(BeFalse())
Expect(IsNameValid(".")).To(BeFalse())
Expect(IsNameValid("..")).To(BeFalse())
Expect(IsNameValid("")).To(BeFalse())
})
})