main_test.go 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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{RootDir: "/",
  10. DBPath: "//var/lib/pacman/",
  11. CacheDir: []string{"/cachedir/", "/another/"},
  12. HookDir: []string{"/hookdir/"},
  13. GPGDir: "/gpgdir/",
  14. LogFile: "/logfile",
  15. HoldPkg: []string(nil),
  16. IgnorePkg: []string{"ignore", "this", "package"},
  17. IgnoreGroup: []string{"ignore", "this", "group"},
  18. Architecture: "8086",
  19. XferCommand: "",
  20. NoUpgrade: []string{"noupgrade"},
  21. NoExtract: []string{"noextract"},
  22. CleanMethod: []string{"KeepInstalled"},
  23. SigLevel: []string{"PackageOptional", "PackageTrustedOnly", "DatabaseOptional", "DatabaseTrustedOnly"},
  24. LocalFileSigLevel: []string(nil),
  25. RemoteFileSigLevel: []string(nil),
  26. UseSyslog: false,
  27. Color: false,
  28. UseDelta: 0,
  29. TotalDownload: true,
  30. CheckSpace: true,
  31. VerbosePkgLists: true,
  32. DisableDownloadTimeout: false,
  33. Repos: []pacmanconf.Repository{
  34. {Name: "repo1", Servers: []string{"repo1"}, SigLevel: []string(nil), Usage: []string{"All"}},
  35. {Name: "repo2", Servers: []string{"repo2"}, SigLevel: []string(nil), Usage: []string{"All"}}}}
  36. pacmanConf, color, err := initAlpm(settings.MakeArguments(), "testdata/pacman.conf")
  37. assert.Nil(t, err)
  38. assert.NotNil(t, pacmanConf)
  39. assert.Equal(t, color, false)
  40. assert.EqualValues(t, expectedPacmanConf, pacmanConf)
  41. }