Parcourir la source

Fixed tests for unified structure

jguer il y a 7 ans
Parent
commit
ef454680dc
4 fichiers modifiés avec 66 ajouts et 65 suppressions
  1. 0 62
      pacman_test.go
  2. 36 0
      print_test.go
  3. 27 0
      query_test.go
  4. 3 3
      vcs_test.go

+ 0 - 62
pacman_test.go

@@ -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 - 0
print_test.go

@@ -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 - 0
query_test.go

@@ -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)
+}

+ 3 - 3
vcs_test.go

@@ -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)
 	}