mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-23 08:47:42 -05:00
e81ccc406b
Change all license headers to comply with REUSE specification. Fix #16132 Co-authored-by: flynnnnnnnnnn <flynnnnnnnnnn@github> Co-authored-by: John Olheiser <john.olheiser@gmail.com>
41 lines
820 B
Go
41 lines
820 B
Go
// Copyright 2020 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package code
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
|
|
"code.gitea.io/gitea/models/unittest"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestESIndexAndSearch(t *testing.T) {
|
|
unittest.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)
|
|
}
|
|
|
|
func TestIndexPos(t *testing.T) {
|
|
startIdx, endIdx := indexPos("test index start and end", "start", "end")
|
|
assert.EqualValues(t, 11, startIdx)
|
|
assert.EqualValues(t, 24, endIdx)
|
|
}
|