yay/main_test.go

62 lines
1.4 KiB
Go
Raw Normal View History

2018-09-10 20:25:38 +00:00
package main
import (
"testing"
"github.com/stretchr/testify/assert"
2020-07-08 01:22:01 +00:00
"github.com/Jguer/yay/v10/pkg/settings"
2018-09-10 20:25:38 +00:00
)
2020-07-05 00:46:48 +00:00
func TestInitAlpm(t *testing.T) {
2020-07-08 01:31:35 +00:00
alpmHandle, pacmanConf, err := initAlpm(settings.MakeArguments(), "testdata/pacman.conf")
assert.Nil(t, err)
assert.NotNil(t, pacmanConf)
2018-09-10 20:25:38 +00:00
h := alpmHandle
root, err := h.Root()
2020-07-05 16:03:22 +00:00
assert.Nil(t, err)
assert.Equal(t, "/", root)
2018-09-10 20:25:38 +00:00
cache, err := h.CacheDirs()
2020-07-05 16:03:22 +00:00
assert.Nil(t, err)
assert.Equal(t, []string{"/cachedir/", "/another/"}, cache.Slice())
2018-09-10 20:25:38 +00:00
log, err := h.LogFile()
2020-07-05 16:03:22 +00:00
assert.Nil(t, err)
assert.Equal(t, "/logfile", log)
2018-09-10 20:25:38 +00:00
gpg, err := h.GPGDir()
2020-07-05 16:03:22 +00:00
assert.Nil(t, err)
assert.Equal(t, "/gpgdir/", gpg)
2018-09-10 20:25:38 +00:00
hook, err := h.HookDirs()
2020-07-05 16:03:22 +00:00
assert.Nil(t, err)
assert.Equal(t, []string{"/usr/share/libalpm/hooks/", "/hookdir/"}, hook.Slice())
2018-09-10 20:25:38 +00:00
arch, err := h.Arch()
2020-07-05 16:03:22 +00:00
assert.Nil(t, err)
assert.Equal(t, "8086", arch)
2018-09-10 20:25:38 +00:00
ignorePkg, err := h.IgnorePkgs()
2020-07-05 16:03:22 +00:00
assert.Nil(t, err)
assert.Equal(t, []string{"ignore", "this", "package"}, ignorePkg.Slice())
2018-09-10 20:25:38 +00:00
ignoreGroup, err := h.IgnoreGroups()
2020-07-05 16:03:22 +00:00
assert.Nil(t, err)
assert.Equal(t, []string{"ignore", "this", "group"}, ignoreGroup.Slice())
2018-09-10 20:25:38 +00:00
noUp, err := h.NoUpgrades()
2020-07-05 16:03:22 +00:00
assert.Nil(t, err)
assert.Equal(t, []string{"noupgrade"}, noUp.Slice())
2018-09-10 20:25:38 +00:00
noEx, err := h.NoExtracts()
2020-07-05 16:03:22 +00:00
assert.Nil(t, err)
assert.Equal(t, []string{"noextract"}, noEx.Slice())
2018-09-10 20:25:38 +00:00
check, err := h.CheckSpace()
2020-07-05 16:03:22 +00:00
assert.Nil(t, err)
assert.Equal(t, true, check)
2018-09-10 20:25:38 +00:00
}