summaryrefslogtreecommitdiffstats
path: root/integrations
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2019-05-21 20:11:09 +0100
committerGitHub <noreply@github.com>2019-05-21 20:11:09 +0100
commit84bfd005377d0693a4ebd52fa305f57fba6be989 (patch)
treede52b0876090473cacfa235ec5e250db0a4204d1 /integrations
parent1f84970de0e510060e608eb94f7aaabc2378eef3 (diff)
downloadgitea-84bfd005377d0693a4ebd52fa305f57fba6be989.tar.gz
gitea-84bfd005377d0693a4ebd52fa305f57fba6be989.zip
Fix TestSearchRepo by waiting till indexing is done (#7004)
* Fix TestSearchRepo by waiting till indexing is done * Update integrations/repo_search_test.go * changes as per @mrsdizzie
Diffstat (limited to 'integrations')
-rw-r--r--integrations/repo_search_test.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/integrations/repo_search_test.go b/integrations/repo_search_test.go
index d7d07ca8d0..3422aeaa12 100644
--- a/integrations/repo_search_test.go
+++ b/integrations/repo_search_test.go
@@ -5,8 +5,12 @@
package integrations
import (
+ "log"
"net/http"
"testing"
+ "time"
+
+ "code.gitea.io/gitea/models"
"github.com/PuerkitoBio/goquery"
"github.com/stretchr/testify/assert"
@@ -27,6 +31,27 @@ func resultFilenames(t testing.TB, doc *HTMLDoc) []string {
func TestSearchRepo(t *testing.T) {
prepareTestEnv(t)
+ repo, err := models.GetRepositoryByOwnerAndName("user2", "repo1")
+ assert.NoError(t, err)
+
+ models.UpdateRepoIndexer(repo)
+
+ log.Printf("Waiting for indexing\n")
+
+ i := 0
+ for i < 60 {
+ if repo.IndexerStatus != nil && len(repo.IndexerStatus.CommitSha) != 0 {
+ break
+ }
+ time.Sleep(1 * time.Second)
+ i++
+ }
+ if i < 60 {
+ log.Printf("Indexing took: %ds\n", i)
+ } else {
+ log.Printf("Waited the limit: %ds for indexing, continuing\n", i)
+ }
+
req := NewRequestf(t, "GET", "/user2/repo1/search?q=Description&page=1")
resp := MakeRequest(t, req, http.StatusOK)