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
|
package main
import (
"github.com/stretchr/testify/assert"
"testing"
. "github.com/githubert/lettersnail/common"
)
func TestExpandTilde(t *testing.T) {
c := NewConfiguration()
c.Set(CONF_WORKDIR, "/foo")
expandTilde(c)
assert.Equal(t, "/foo", c.Get(CONF_WORKDIR))
c.Set(CONF_WORKDIR, "~/foo")
expandTilde(c)
assert.Equal(t, userHome() + "/foo", c.Get(CONF_WORKDIR))
// Shortest possible
c.Set(CONF_WORKDIR, "~/")
expandTilde(c)
assert.Equal(t, userHome(), c.Get(CONF_WORKDIR))
// Single character workdir with only a tilde
c.Set(CONF_WORKDIR, "~")
expandTilde(c)
assert.Equal(t, userHome(), c.Get(CONF_WORKDIR))
// Ignored tilde
c.Set(CONF_WORKDIR, "~test")
expandTilde(c)
assert.Equal(t, "~test", c.Get(CONF_WORKDIR))
}
|