summaryrefslogtreecommitdiffstats
path: root/modules/indexer/code/elastic_search_test.go
blob: a230939746348efdf27f2138c872392855040974 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// 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)
}