-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathinstallvar_test.go
52 lines (44 loc) · 1.2 KB
/
installvar_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
// Copyright 2017 Debpkg authors. All rights reserved.
// Use of this source code is governed by the MIT
// license that can be found in the LICENSE file.
package debpkg
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestVarInit(t *testing.T) {
tvs := map[string]string{
"INSTALLPREFIX": DefaultInstallPrefix,
"BINDIR": DefaultBinDir,
"SBINDIR": DefaultSbinDir,
"SYSCONFDIR": DefaultSysConfDir,
"DATAROOTDIR": DefaultDataRootDir,
}
for v, exp := range tvs {
assert.Equal(t, exp, GetVar(v))
}
}
func TestGetVarWithPrefix(t *testing.T) {
tvs := map[string]string{
"BINDIR": "/usr/bin",
"SBINDIR": "/usr/sbin",
"SYSCONFDIR": "/usr/etc", // FIXME should not be possible -> "/etc"
"DATAROOTDIR": "/usr/share",
}
for v, exp := range tvs {
assert.Equal(t, exp, GetVarWithPrefix(v))
}
}
func TestExpandVarBinDir(t *testing.T) {
tvs := map[string]string{
"{{.BINDIR}}": "/usr/bin",
"{{.SBINDIR}}": "/usr/sbin",
"{{.SYSCONFDIR}}": "/usr/etc", // FIXME should not be possible -> "/etc"
"{{.DATAROOTDIR}}": "/usr/share",
}
for val, exp := range tvs {
res, err := ExpandVar(val)
assert.Nil(t, err)
assert.Equal(t, exp, res)
}
}