File tree 2 files changed +15
-15
lines changed
2 files changed +15
-15
lines changed Original file line number Diff line number Diff line change 6
6
test :
7
7
name : Test
8
8
runs-on : ubuntu-latest
9
+ container :
10
+ image : node:18
9
11
strategy :
10
12
matrix :
11
- searchdb-port : [9207, 9208, 9201 ]
13
+ searchdb-host : [elastic7, elastic8, opensearch1 ]
12
14
fail-fast : false
13
15
14
16
services :
@@ -18,26 +20,18 @@ jobs:
18
20
POSTGRES_DB : indexer_test
19
21
POSTGRES_USER : indexer_test
20
22
POSTGRES_PASSWORD : temba
21
- ports :
22
- - 5432:5432
23
23
options : --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
24
24
elastic7 :
25
25
image : elasticsearch:7.17.9
26
- ports :
27
- - 9207:9200
28
26
env :
29
27
discovery.type : single-node
30
28
elastic8 :
31
29
image : elasticsearch:8.13.4
32
- ports :
33
- - 9208:9200
34
30
env :
35
31
discovery.type : single-node
36
32
xpack.security.enabled : false
37
33
opensearch1 :
38
34
image : opensearchproject/opensearch:1.3.16
39
- ports :
40
- - 9201:9200
41
35
env :
42
36
discovery.type : single-node
43
37
plugins.security.disabled : true
53
47
54
48
- name : Setup environment
55
49
run : |
56
- echo "INDEXER_ELASTIC_URL=http://localhost:${{ matrix.searchdb-port }}" >> "$GITHUB_ENV"
50
+ echo "INDEXER_DB=postgres://indexer_test:temba@postgres:5432/indexer_test?sslmode=disable" >> "$GITHUB_ENV"
51
+ echo "INDEXER_ELASTIC_URL=http://${{ matrix.searchdb-host }}:9200" >> "$GITHUB_ENV"
57
52
58
53
- name : Run tests
59
54
run : go test -p=1 -coverprofile=coverage.text -covermode=atomic ./...
Original file line number Diff line number Diff line change @@ -23,13 +23,18 @@ import (
23
23
24
24
const aliasName = "indexer_test"
25
25
26
+ func getenv (key , def string ) string {
27
+ val := os .Getenv (key )
28
+ if val == "" {
29
+ return def
30
+ }
31
+ return val
32
+ }
33
+
26
34
func setup (t * testing.T ) (* indexer.Config , * sql.DB ) {
27
35
cfg := indexer .NewDefaultConfig ()
28
- cfg .DB = "postgres://indexer_test:temba@localhost:5432/indexer_test?sslmode=disable"
29
- cfg .ElasticURL = os .Getenv ("INDEXER_ELASTIC_URL" )
30
- if cfg .ElasticURL == "" {
31
- cfg .ElasticURL = "http://localhost:9200"
32
- }
36
+ cfg .DB = getenv ("INDEXER_DB" , "postgres://indexer_test:temba@localhost:5432/indexer_test?sslmode=disable" )
37
+ cfg .ElasticURL = getenv ("INDEXER_ELASTIC_URL" , "http://localhost:9200" )
33
38
34
39
testDB , err := os .ReadFile ("../testdb.sql" )
35
40
require .NoError (t , err )
You can’t perform that action at this time.
0 commit comments