1
0
mirror of https://github.com/Jguer/yay synced 2024-07-03 08:51:44 +00:00

Fixed tests for unified structure

This commit is contained in:
jguer 2017-08-07 10:53:20 +01:00
parent 418c27f7e3
commit ef454680dc
4 changed files with 66 additions and 65 deletions

View File

@ -1,62 +0,0 @@
package main
import (
"os"
"testing"
"github.com/jguer/yay/config"
)
func benchmarkPrintSearch(search string, b *testing.B) {
old := os.Stdout
_, w, _ := os.Pipe()
os.Stdout = w
for n := 0; n < b.N; n++ {
res, _, _ := Search(append([]string{}, search))
res.PrintSearch()
}
os.Stdout = old
}
func BenchmarkPrintSearchSimpleTopDown(b *testing.B) {
config.YayConf.SortMode = config.TopDown
benchmarkPrintSearch("chromium", b)
}
func BenchmarkPrintSearchComplexTopDown(b *testing.B) {
config.YayConf.SortMode = config.TopDown
benchmarkPrintSearch("linux", b)
}
func BenchmarkPrintSearchSimpleBottomUp(b *testing.B) {
config.YayConf.SortMode = config.BottomUp
benchmarkPrintSearch("chromium", b)
}
func BenchmarkPrintSearchComplexBottomUp(b *testing.B) {
config.YayConf.SortMode = config.BottomUp
benchmarkPrintSearch("linux", b)
}
func benchmarkSearch(search string, b *testing.B) {
for n := 0; n < b.N; n++ {
Search(append([]string{}, search))
}
}
func BenchmarkSearchSimpleTopDown(b *testing.B) {
config.YayConf.SortMode = config.TopDown
benchmarkSearch("chromium", b)
}
func BenchmarkSearchSimpleBottomUp(b *testing.B) {
config.YayConf.SortMode = config.BottomUp
benchmarkSearch("chromium", b)
}
func BenchmarkSearchComplexTopDown(b *testing.B) {
config.YayConf.SortMode = config.TopDown
benchmarkSearch("linux", b)
}
func BenchmarkSearchComplexBottomUp(b *testing.B) {
config.YayConf.SortMode = config.BottomUp
benchmarkSearch("linux", b)
}

36
print_test.go Normal file
View File

@ -0,0 +1,36 @@
package main
import (
"os"
"testing"
)
func benchmarkPrintSearch(search string, b *testing.B) {
old := os.Stdout
_, w, _ := os.Pipe()
os.Stdout = w
for n := 0; n < b.N; n++ {
res, _, _ := queryRepo(append([]string{}, search))
res.printSearch()
}
os.Stdout = old
}
func BenchmarkPrintSearchSimpleTopDown(b *testing.B) {
config.SortMode = TopDown
benchmarkPrintSearch("chromium", b)
}
func BenchmarkPrintSearchComplexTopDown(b *testing.B) {
config.SortMode = TopDown
benchmarkPrintSearch("linux", b)
}
func BenchmarkPrintSearchSimpleBottomUp(b *testing.B) {
config.SortMode = BottomUp
benchmarkPrintSearch("chromium", b)
}
func BenchmarkPrintSearchComplexBottomUp(b *testing.B) {
config.SortMode = BottomUp
benchmarkPrintSearch("linux", b)
}

27
query_test.go Normal file
View File

@ -0,0 +1,27 @@
package main
import "testing"
func benchmarkSearch(search string, b *testing.B) {
for n := 0; n < b.N; n++ {
queryRepo(append([]string{}, search))
}
}
func BenchmarkSearchSimpleTopDown(b *testing.B) {
config.SortMode = TopDown
benchmarkSearch("chromium", b)
}
func BenchmarkSearchSimpleBottomUp(b *testing.B) {
config.SortMode = BottomUp
benchmarkSearch("chromium", b)
}
func BenchmarkSearchComplexTopDown(b *testing.B) {
config.SortMode = TopDown
benchmarkSearch("linux", b)
}
func BenchmarkSearchComplexBottomUp(b *testing.B) {
config.SortMode = BottomUp
benchmarkSearch("linux", b)
}

View File

@ -12,20 +12,20 @@ func TestParsing(t *testing.T) {
}
neovim := source{sourceurl: "git+https://github.com/neovim/neovim.git"}
neovim.owner, neovim.repo = ParseSource(neovim.sourceurl)
neovim.owner, neovim.repo = parseSource(neovim.sourceurl)
if neovim.owner != "neovim" || neovim.repo != "neovim" {
t.Fatalf("Expected to find neovim/neovim, found %+v/%+v", neovim.owner, neovim.repo)
}
yay := source{sourceurl: "git://github.com/jguer/yay.git#branch=master"}
yay.owner, yay.repo = ParseSource(yay.sourceurl)
yay.owner, yay.repo = parseSource(yay.sourceurl)
if yay.owner != "jguer" || yay.repo != "yay" {
t.Fatalf("Expected to find jguer/yay, found %+v/%+v", yay.owner, yay.repo)
}
ack := source{sourceurl: "git://github.com/davidgiven/ack"}
ack.owner, ack.repo = ParseSource(ack.sourceurl)
ack.owner, ack.repo = parseSource(ack.sourceurl)
if ack.owner != "davidgiven" || ack.repo != "ack" {
t.Fatalf("Expected to find davidgiven/ack, found %+v/%+v", ack.owner, ack.repo)
}