mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 16:40:24 +08:00 
			
		
		
		
	* Support elastic search for code search * Finished elastic search implementation and add some tests * Enable test on drone and added docs * Add new fields to elastic search * Fix bug * remove unused changes * Use indexer alias to keep the gitea indexer version * Improve codes * Some code improvements * The real indexer name changed to xxx.v1 Co-authored-by: zeripath <art27@cantab.net>
		
			
				
	
	
		
			37 lines
		
	
	
		
			698 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			37 lines
		
	
	
		
			698 B
		
	
	
	
		
			Go
		
	
	
	
	
	
// Copyright 2020 The Gitea Authors. All rights reserved.
 | 
						|
// Use of this source code is governed by a MIT-style
 | 
						|
// license that can be found in the LICENSE file.
 | 
						|
 | 
						|
package code
 | 
						|
 | 
						|
import (
 | 
						|
	"os"
 | 
						|
	"testing"
 | 
						|
 | 
						|
	"code.gitea.io/gitea/models"
 | 
						|
 | 
						|
	"github.com/stretchr/testify/assert"
 | 
						|
)
 | 
						|
 | 
						|
func TestESIndexAndSearch(t *testing.T) {
 | 
						|
	models.PrepareTestEnv(t)
 | 
						|
 | 
						|
	u := os.Getenv("TEST_INDEXER_CODE_ES_URL")
 | 
						|
	if u == "" {
 | 
						|
		t.SkipNow()
 | 
						|
		return
 | 
						|
	}
 | 
						|
 | 
						|
	indexer, _, err := NewElasticSearchIndexer(u, "gitea_codes")
 | 
						|
	if err != nil {
 | 
						|
		assert.Fail(t, "Unable to create ES indexer Error: %v", err)
 | 
						|
		if indexer != nil {
 | 
						|
			indexer.Close()
 | 
						|
		}
 | 
						|
		return
 | 
						|
	}
 | 
						|
	defer indexer.Close()
 | 
						|
 | 
						|
	testIndexer("elastic_search", t, indexer)
 | 
						|
}
 |