main_test.go 1.7 KB

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