mirror of
https://github.com/go-gitea/gitea
synced 2024-11-05 09:44:26 +00:00
36943e56d6
* add Divergence * add Update Button * first working version * re-use code * split raw merge commands and db-change functions (notify, cache, ...) * use rawMerge (remove redundant code) * own function to get Diverging of PRs * use FlashError * correct Error Msg * hook is triggerd ... so remove comment * add "branch2" to "user2/repo1" because it unit-test "TestPullView_ReviewerMissed" use it but dont exist jet :/ * move GetPerm to IsUserAllowedToUpdate * add Flash Success MSG * imprufe code - remove useless js chage * fix-lint * TEST: add PullRequest ID:5 Repo: user2/repo1 Base: branch1 Head: pr-to-update * correct comments * make PR5 outdated * fix Tests * WIP: add pull update test * update revs * update locales * working TEST * update UI * misspell * change style * add 1s delay so rev exist * move row up (before merge row) * fix lint nit * UI remove divider * Update style * nits * do it right * introduce IsSameRepo * remove useless check Co-authored-by: Lauris BH <lauris@nix.lv>
98 lines
2.4 KiB
Go
98 lines
2.4 KiB
Go
// Copyright 2019 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 issues
|
|
|
|
import (
|
|
"io/ioutil"
|
|
"os"
|
|
"path"
|
|
"path/filepath"
|
|
"testing"
|
|
"time"
|
|
|
|
"code.gitea.io/gitea/models"
|
|
"code.gitea.io/gitea/modules/setting"
|
|
|
|
"gopkg.in/ini.v1"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestMain(m *testing.M) {
|
|
models.MainTest(m, filepath.Join("..", "..", ".."))
|
|
}
|
|
|
|
func TestBleveSearchIssues(t *testing.T) {
|
|
assert.NoError(t, models.PrepareTestDatabase())
|
|
setting.Cfg = ini.Empty()
|
|
|
|
tmpIndexerDir, err := ioutil.TempDir("", "issues-indexer")
|
|
if err != nil {
|
|
assert.Fail(t, "Unable to create temporary directory: %v", err)
|
|
return
|
|
}
|
|
oldQueueDir := setting.Indexer.IssueQueueDir
|
|
oldIssuePath := setting.Indexer.IssuePath
|
|
setting.Indexer.IssueQueueDir = path.Join(tmpIndexerDir, "issues.queue")
|
|
setting.Indexer.IssuePath = path.Join(tmpIndexerDir, "issues.queue")
|
|
defer func() {
|
|
setting.Indexer.IssueQueueDir = oldQueueDir
|
|
setting.Indexer.IssuePath = oldIssuePath
|
|
os.RemoveAll(tmpIndexerDir)
|
|
}()
|
|
|
|
setting.Indexer.IssueType = "bleve"
|
|
setting.NewQueueService()
|
|
InitIssueIndexer(true)
|
|
defer func() {
|
|
indexer := holder.get()
|
|
if bleveIndexer, ok := indexer.(*BleveIndexer); ok {
|
|
bleveIndexer.Close()
|
|
}
|
|
}()
|
|
|
|
time.Sleep(5 * time.Second)
|
|
|
|
ids, err := SearchIssuesByKeyword([]int64{1}, "issue2")
|
|
assert.NoError(t, err)
|
|
assert.EqualValues(t, []int64{2}, ids)
|
|
|
|
ids, err = SearchIssuesByKeyword([]int64{1}, "first")
|
|
assert.NoError(t, err)
|
|
assert.EqualValues(t, []int64{1}, ids)
|
|
|
|
ids, err = SearchIssuesByKeyword([]int64{1}, "for")
|
|
assert.NoError(t, err)
|
|
assert.EqualValues(t, []int64{1, 2, 3, 5, 11}, ids)
|
|
|
|
ids, err = SearchIssuesByKeyword([]int64{1}, "good")
|
|
assert.NoError(t, err)
|
|
assert.EqualValues(t, []int64{1}, ids)
|
|
|
|
}
|
|
|
|
func TestDBSearchIssues(t *testing.T) {
|
|
assert.NoError(t, models.PrepareTestDatabase())
|
|
|
|
setting.Indexer.IssueType = "db"
|
|
InitIssueIndexer(true)
|
|
|
|
ids, err := SearchIssuesByKeyword([]int64{1}, "issue2")
|
|
assert.NoError(t, err)
|
|
assert.EqualValues(t, []int64{2}, ids)
|
|
|
|
ids, err = SearchIssuesByKeyword([]int64{1}, "first")
|
|
assert.NoError(t, err)
|
|
assert.EqualValues(t, []int64{1}, ids)
|
|
|
|
ids, err = SearchIssuesByKeyword([]int64{1}, "for")
|
|
assert.NoError(t, err)
|
|
assert.EqualValues(t, []int64{1, 2, 3, 5, 11}, ids)
|
|
|
|
ids, err = SearchIssuesByKeyword([]int64{1}, "good")
|
|
assert.NoError(t, err)
|
|
assert.EqualValues(t, []int64{1}, ids)
|
|
}
|