pacman_test.go 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. //go:build !integration
  2. // +build !integration
  3. package settings
  4. import (
  5. "testing"
  6. "github.com/Morganamilo/go-pacmanconf"
  7. "github.com/stretchr/testify/assert"
  8. "github.com/Jguer/yay/v12/pkg/settings/parser"
  9. )
  10. func TestPacmanConf(t *testing.T) {
  11. t.Parallel()
  12. expectedPacmanConf := &pacmanconf.Config{
  13. RootDir: "/",
  14. DBPath: "//var/lib/pacman/",
  15. CacheDir: []string{"/cachedir/", "/another/"},
  16. HookDir: []string{"/hookdir/"},
  17. GPGDir: "/gpgdir/",
  18. LogFile: "/logfile",
  19. HoldPkg: []string(nil),
  20. IgnorePkg: []string{"ignore", "this", "package"},
  21. IgnoreGroup: []string{"ignore", "this", "group"},
  22. Architecture: []string{"8086"},
  23. XferCommand: "",
  24. NoUpgrade: []string{"noupgrade"},
  25. NoExtract: []string{"noextract"},
  26. CleanMethod: []string{"KeepInstalled"},
  27. SigLevel: []string{"PackageOptional", "PackageTrustedOnly", "DatabaseOptional", "DatabaseTrustedOnly"},
  28. LocalFileSigLevel: []string(nil),
  29. RemoteFileSigLevel: []string(nil),
  30. UseSyslog: false,
  31. Color: false,
  32. UseDelta: 0,
  33. TotalDownload: false,
  34. CheckSpace: true,
  35. VerbosePkgLists: true,
  36. DisableDownloadTimeout: false,
  37. Repos: []pacmanconf.Repository{
  38. {Name: "repo1", Servers: []string{"repo1"}, SigLevel: []string(nil), Usage: []string{"All"}},
  39. {Name: "repo2", Servers: []string{"repo2"}, SigLevel: []string(nil), Usage: []string{"All"}},
  40. },
  41. }
  42. pacmanConf, color, err := RetrievePacmanConfig(parser.MakeArguments(), "../../testdata/pacman.conf")
  43. assert.Nil(t, err)
  44. assert.NotNil(t, pacmanConf)
  45. assert.Equal(t, color, false)
  46. assert.EqualValues(t, expectedPacmanConf, pacmanConf)
  47. }