mirror of
https://github.com/Jguer/yay.git
synced 2024-11-07 01:27:21 +01:00
20a98de384
=== RUN TestSearch --- PASS: TestSearch (0.38s) === RUN TestInfo --- PASS: TestInfo (0.08s) === RUN TestUpdate :: Starting AUR upgrade... ==> arduino: 1:1.6.12-3 -> 1:1.6.12-4 ==> Proceed with upgrade (Y/n) ==> Installing arduino ==> Edit PKGBUILD? (y/N) --- PASS: TestUpdate (1.15s) === RUN TestUpgrade :: Starting AUR upgrade... ==> arduino: 1:1.6.12-4 -> 1:1.6.12-3 ==> Proceed with upgrade (Y/n) ==> Installing arduino ==> Edit PKGBUILD? (y/N) --- PASS: TestUpgrade (1.07s) PASS BenchMark Update 2 1022581207 ns/op 2034108 B/op 14345 allocs/op BenchMark Upgrade 2 956533245 ns/op 662720 B/op 11738 allocs/op
130 lines
2.6 KiB
Go
130 lines
2.6 KiB
Go
package aur
|
|
|
|
import (
|
|
"os"
|
|
"reflect"
|
|
"testing"
|
|
|
|
"github.com/demizer/go-alpm"
|
|
)
|
|
|
|
func TestSearch(t *testing.T) {
|
|
eN := "yay"
|
|
eD := "Yet another pacman wrapper with AUR support"
|
|
result, _, err := Search("yay", true)
|
|
if err != nil {
|
|
t.Fatalf("Expected err to be nil but it was %s", err)
|
|
}
|
|
|
|
// t.Logf("Got struct: %+v", result)
|
|
found := false
|
|
for _, v := range result {
|
|
if v.Name == eN && v.Description == eD {
|
|
found = true
|
|
}
|
|
}
|
|
|
|
if !found {
|
|
t.Fatalf("Expected to find yay, found %+v", result)
|
|
}
|
|
}
|
|
|
|
func benchmarkSearch(search string, sort bool, b *testing.B) {
|
|
for n := 0; n < b.N; n++ {
|
|
Search(search, sort)
|
|
}
|
|
}
|
|
|
|
func BenchmarkSearchSimpleNoSort(b *testing.B) { benchmarkSearch("yay", false, b) }
|
|
func BenchmarkSearchComplexNoSort(b *testing.B) { benchmarkSearch("linux", false, b) }
|
|
func BenchmarkSearchSimpleSorted(b *testing.B) { benchmarkSearch("yay", true, b) }
|
|
func BenchmarkSearchComplexSorted(b *testing.B) { benchmarkSearch("linux", true, b) }
|
|
|
|
func TestInfo(t *testing.T) {
|
|
eN := "yay"
|
|
eD := "Yet another pacman wrapper with AUR support"
|
|
eM := []string{"go", "git"}
|
|
result, _, err := Info("yay")
|
|
if err != nil {
|
|
t.Fatalf("Expected err to be nil but it was %s", err)
|
|
}
|
|
|
|
// t.Logf("Got struct: %+v", result)
|
|
found := false
|
|
for _, v := range result {
|
|
if v.Name == eN && v.Description == eD && reflect.DeepEqual(v.MakeDepends, eM) {
|
|
found = true
|
|
}
|
|
}
|
|
|
|
if !found {
|
|
t.Fatalf("Expected to find yay, found %+v", result)
|
|
}
|
|
}
|
|
|
|
func TestUpdate(t *testing.T) {
|
|
var conf alpm.PacmanConfig
|
|
file, err := os.Open("/etc/pacman.conf")
|
|
if err != nil {
|
|
return
|
|
}
|
|
conf, err = alpm.ParseConfig(file)
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
err = UpdatePackages("/tmp/yaytmp", &conf, []string{})
|
|
if err != nil {
|
|
t.Fatalf("Expected err to be nil but it was %s", err)
|
|
}
|
|
}
|
|
|
|
func TestUpgrade(t *testing.T) {
|
|
var conf alpm.PacmanConfig
|
|
file, err := os.Open("/etc/pacman.conf")
|
|
if err != nil {
|
|
return
|
|
}
|
|
conf, err = alpm.ParseConfig(file)
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
err = Upgrade("/tmp/yaytmp", &conf, []string{})
|
|
if err != nil {
|
|
t.Fatalf("Expected err to be nil but it was %s", err)
|
|
}
|
|
}
|
|
|
|
func BenchmarkUpdate(b *testing.B) {
|
|
var conf alpm.PacmanConfig
|
|
file, err := os.Open("/etc/pacman.conf")
|
|
if err != nil {
|
|
return
|
|
}
|
|
conf, err = alpm.ParseConfig(file)
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
for n := 0; n < b.N; n++ {
|
|
UpdatePackages("/tmp/yaytmp", &conf, []string{})
|
|
}
|
|
}
|
|
|
|
func BenchmarkUpgrade(b *testing.B) {
|
|
var conf alpm.PacmanConfig
|
|
file, err := os.Open("/etc/pacman.conf")
|
|
if err != nil {
|
|
return
|
|
}
|
|
conf, err = alpm.ParseConfig(file)
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
for n := 0; n < b.N; n++ {
|
|
Upgrade("/tmp/yaytmp", &conf, []string{})
|
|
}
|
|
}
|