forked from 99designs/keyring
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tilde_test.go
41 lines (37 loc) · 841 Bytes
/
tilde_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
//go:build linux
// +build linux
package keyring
import "testing"
func TestExpandTilde(t *testing.T) {
t.Setenv("HOME", "/home/testing")
actual, err := ExpandTilde("~/one/two")
if err != nil {
t.Fatal(err)
}
expected := "/home/testing/one/two"
if actual != expected {
t.Fatalf("%s != %s", expected, actual)
}
}
func TestExpandTildeWithoutSlash(t *testing.T) {
t.Setenv("HOME", "/home/testing")
actual, err := ExpandTilde("~one/two")
if err != nil {
t.Fatal(err)
}
expected := "~one/two"
if actual != expected {
t.Fatalf("%s != %s", expected, actual)
}
}
func TestExpandTildeWithoutLeadingTilde(t *testing.T) {
t.Setenv("HOME", "/home/testing")
actual, err := ExpandTilde("one/two~")
if err != nil {
t.Fatal(err)
}
expected := "one/two~"
if actual != expected {
t.Fatalf("%s != %s", expected, actual)
}
}