-
Notifications
You must be signed in to change notification settings - Fork 0
/
path_test.go
65 lines (48 loc) · 1.4 KB
/
path_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
53
54
55
56
57
58
59
60
61
62
63
64
65
package pathutils_test
import (
. "github.com/koofr/go-pathutils"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
var _ = Describe("Path", func() {
Describe("SplitNameExt", func() {
It("should split name", func() {
name, ext := SplitNameExt("file.txt")
Expect(name).To(Equal("file"))
Expect(ext).To(Equal("txt"))
})
It("should split name without ext", func() {
name, ext := SplitNameExt("file")
Expect(name).To(Equal("file"))
Expect(ext).To(Equal(""))
})
It("should split name with multiple exts", func() {
name, ext := SplitNameExt("file.tar.gz")
Expect(name).To(Equal("file.tar"))
Expect(ext).To(Equal("gz"))
})
It("should split name with ext only", func() {
name, ext := SplitNameExt(".gitignore")
Expect(name).To(Equal(""))
Expect(ext).To(Equal("gitignore"))
})
})
Describe("JoinNameExt", func() {
It("should join name and ext", func() {
fileName := JoinNameExt("file", "txt")
Expect(fileName).To(Equal("file.txt"))
})
It("should join name without ext", func() {
fileName := JoinNameExt("file", "")
Expect(fileName).To(Equal("file"))
})
It("should join name with multiple exts", func() {
fileName := JoinNameExt("file.tar", "gz")
Expect(fileName).To(Equal("file.tar.gz"))
})
It("should join ext only", func() {
fileName := JoinNameExt("", "gitignore")
Expect(fileName).To(Equal(".gitignore"))
})
})
})