forked from Jguer/yay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig_test.go
59 lines (43 loc) · 1.42 KB
/
config_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
package main
import (
"reflect"
"testing"
)
func expect(t *testing.T, field string, a interface{}, b interface{}, err error) {
if err != nil {
t.Error(err)
} else if !reflect.DeepEqual(a, b) {
t.Errorf("%s expected: %s got %s", field, a, b)
}
}
func TestConfig(t *testing.T) {
config = &Configuration{}
config.PacmanConf = "./testdata/pacman.conf"
err := initAlpm()
if err != nil {
t.Fatal(err)
}
h := alpmHandle
root, err := h.Root()
expect(t, "RootDir", "/", root, err)
cache, err := h.CacheDirs()
expect(t, "CacheDir", []string{"/cachedir/", "/another/"}, cache.Slice(), err)
log, err := h.LogFile()
expect(t, "LogFile", "/logfile", log, err)
gpg, err := h.GPGDir()
expect(t, "GPGDir", "/gpgdir/", gpg, err)
hook, err := h.HookDirs()
expect(t, "HookDir", []string{"/usr/share/libalpm/hooks/", "/hookdir/"}, hook.Slice(), err)
arch, err := h.Arch()
expect(t, "Architecture", "8086", arch, err)
ignorePkg, err := h.IgnorePkgs()
expect(t, "IgnorePkg", []string{"ignore", "this", "package"}, ignorePkg.Slice(), err)
ignoreGroup, err := h.IgnoreGroups()
expect(t, "IgnoreGroup", []string{"ignore", "this", "group"}, ignoreGroup.Slice(), err)
noUp, err := h.NoUpgrades()
expect(t, "NoUpgrade", []string{"noupgrade"}, noUp.Slice(), err)
noEx, err := h.NoExtracts()
expect(t, "NoExtract", []string{"noextract"}, noEx.Slice(), err)
check, err := h.CheckSpace()
expect(t, "CheckSpace", true, check, err)
}