main_test.go 1.8 KB

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