forked from cooperspencer/gickup
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_test.go
More file actions
36 lines (28 loc) · 765 Bytes
/
Copy pathmain_test.go
File metadata and controls
36 lines (28 loc) · 765 Bytes
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
package main
import (
"strings"
"testing"
)
func TestTildeReplacement_NoAction(t *testing.T) {
t.Parallel()
if path := "/boop"; substituteHomeForTildeInPath(path) != path {
t.Error("Altered path when no alteration was expected")
}
}
func TestTildeReplacement_TildeOnly(t *testing.T) {
t.Parallel()
if path := "~"; substituteHomeForTildeInPath(path) == path {
t.Error("Path unaltered when alteration was expected")
}
}
func TestTildeReplacement_TildeDir(t *testing.T) {
t.Parallel()
path := "~/boop"
actual := substituteHomeForTildeInPath(path)
if strings.HasPrefix(actual, "~") {
t.Error("Altered path still contains ~")
}
if !strings.HasSuffix(actual, "boop") {
t.Error("Altered path does not end with directory to be retained")
}
}