Skip to content

Commit caa4392

Browse files
committed
Fix test
1 parent 592e2ca commit caa4392

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

modules/indexer/issues/indexer_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212

1313
"code.gitea.io/gitea/models"
1414
"code.gitea.io/gitea/modules/setting"
15+
"gopkg.in/ini.v1"
1516

1617
"github.com/stretchr/testify/assert"
1718
)
@@ -22,10 +23,12 @@ func TestMain(m *testing.M) {
2223

2324
func TestBleveSearchIssues(t *testing.T) {
2425
assert.NoError(t, models.PrepareTestDatabase())
26+
setting.Cfg = ini.Empty()
2527

2628
os.RemoveAll(setting.Indexer.IssueQueueDir)
2729
os.RemoveAll(setting.Indexer.IssuePath)
2830
setting.Indexer.IssueType = "bleve"
31+
setting.NewQueueService()
2932
InitIssueIndexer(true)
3033

3134
time.Sleep(5 * time.Second)

modules/queue/queue_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44

55
package queue
66

7-
import "testing"
7+
import (
8+
"encoding/json"
9+
"testing"
810

9-
import "github.com/stretchr/testify/assert"
10-
11-
import "encoding/json"
11+
"github.com/stretchr/testify/assert"
12+
)
1213

1314
type testData struct {
1415
TestString string

modules/setting/queue.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,9 @@ func getQueueSettings(name string) queueSettings {
115115
return q
116116
}
117117

118-
func newQueueService() {
118+
// NewQueueService sets up the default settings for Queues
119+
// This is exported for tests to be able to use the queue
120+
func NewQueueService() {
119121
sec := Cfg.Section("queue")
120122
Queue.DataDir = sec.Key("DATADIR").MustString("queues/")
121123
if !path.IsAbs(Queue.DataDir) {

modules/setting/setting.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1090,5 +1090,5 @@ func NewServices() {
10901090
newMigrationsService()
10911091
newIndexerService()
10921092
newTaskService()
1093-
newQueueService()
1093+
NewQueueService()
10941094
}

0 commit comments

Comments
 (0)