This repository was archived by the owner on Sep 2, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 7 files changed +35
-19
lines changed Expand file tree Collapse file tree 7 files changed +35
-19
lines changed Original file line number Diff line number Diff line change
1
+ name : Go
2
+
3
+ on :
4
+ push :
5
+ branches : [ main ]
6
+ pull_request :
7
+ branches : [ main ]
8
+
9
+ jobs :
10
+
11
+ build :
12
+ runs-on : ubuntu-latest
13
+ steps :
14
+ - uses : actions/checkout@v2
15
+
16
+ - name : Start containers (PostgreSQL, MongoDB, Redis)
17
+ run : docker-compose -f "docker-compose-unittest.yml" up -d
18
+
19
+ - name : Set up Go
20
+ uses : actions/setup-go@v2
21
+ with :
22
+ go-version : 1.17
23
+
24
+ - name : Build
25
+ run : make build
26
+
27
+ - name : Test
28
+ run : make alltest
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ deploy: build
12
12
scp -qr ./templates/* sb-poc:/home/dstpierre/templates/
13
13
14
14
alltest :
15
- @JWT_SECRET=okdevmode go test --race --cover $( go list ./... | grep -v /postgres-data/ )
15
+ @JWT_SECRET=okdevmode go test --race --cover ./...
16
16
17
17
test-pg :
18
18
@JWT_SECRET=okdevmode go test --race --cover ./database/postgresql
Original file line number Diff line number Diff line change @@ -12,7 +12,6 @@ import (
12
12
13
13
type LocalExecData struct {
14
14
ID primitive.ObjectID `bson:"_id" json:"id"`
15
- AccountID primitive.ObjectID `bson:"accountId" json:"accountId"`
16
15
FunctionName string `bson:"name" json:"name"`
17
16
TriggerTopic string `bson:"tr" json:"trigger"`
18
17
Code string `bson:"code" json:"code"`
@@ -38,15 +37,8 @@ func toLocalExecData(ex internal.ExecData) LocalExecData {
38
37
return LocalExecData {}
39
38
}
40
39
41
- aid , err := primitive .ObjectIDFromHex (ex .AccountID )
42
- if err != nil {
43
- //TODO: fin a way to handle this error properly
44
- return LocalExecData {}
45
- }
46
-
47
40
return LocalExecData {
48
41
ID : oid ,
49
- AccountID : aid ,
50
42
FunctionName : ex .FunctionName ,
51
43
TriggerTopic : ex .TriggerTopic ,
52
44
Code : ex .Code ,
@@ -77,7 +69,6 @@ func toLocalExecHistory(h []internal.ExecHistory) []LocalExecHistory {
77
69
func fromLocalExecData (lex LocalExecData ) internal.ExecData {
78
70
return internal.ExecData {
79
71
ID : lex .ID .Hex (),
80
- AccountID : lex .AccountID .Hex (),
81
72
FunctionName : lex .FunctionName ,
82
73
TriggerTopic : lex .TriggerTopic ,
83
74
Code : lex .Code ,
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ services:
4
4
mongo :
5
5
image : mongo:3-stretch
6
6
volumes :
7
- - ./mongodata:/data/db/mongo
7
+ - .. /mongodata:/data/db/mongo
8
8
ports :
9
9
- " 27017:27017"
10
10
Original file line number Diff line number Diff line change @@ -10,13 +10,10 @@ services:
10
10
- POSTGRES_USER=postgres
11
11
- POSTGRES_PASSWORD=postgres
12
12
volumes :
13
- - ./postgres-data:/var/lib/postgresql/data
14
13
- ./sql/0001_bootstrap_db.sql:/docker-entrypoint-initdb.d/create_tables.sql
15
14
16
15
mongo :
17
16
image : mongo:3-stretch
18
- volumes :
19
- - ./mongodata:/data/db/mongo
20
17
ports :
21
18
- " 27017:27017"
22
19
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ services:
10
10
- POSTGRES_USER=postgres
11
11
- POSTGRES_PASSWORD=postgres
12
12
volumes :
13
- - ./postgres-data:/var/lib/postgresql/data
13
+ - .. /postgres-data:/var/lib/postgresql/data
14
14
- ./sql/0001_bootstrap_db.sql:/docker-entrypoint-initdb.d/create_tables.sql
15
15
16
16
redis :
Original file line number Diff line number Diff line change @@ -36,24 +36,24 @@ var (
36
36
)
37
37
38
38
func TestMain (m * testing.M ) {
39
+ volatile = cache .NewCache ()
40
+
39
41
if strings .EqualFold (os .Getenv ("DATA_STORE" ), "mongo" ) {
40
42
cl , err := openMongoDatabase ("mongodb://localhost:27017" )
41
43
if err != nil {
42
44
log .Fatal (err )
43
45
}
44
46
45
- datastore = mongo .New (cl )
47
+ datastore = mongo .New (cl , volatile . PublishDocument )
46
48
} else {
47
49
dbConn , err := openPGDatabase ("user=postgres password=postgres dbname=postgres sslmode=disable" )
48
50
if err != nil {
49
51
log .Fatal (err )
50
52
}
51
53
52
- datastore = postgresql .New (dbConn )
54
+ datastore = postgresql .New (dbConn , volatile . PublishDocument )
53
55
}
54
56
55
- volatile = cache .NewCache ()
56
-
57
57
database = & Database {cache : volatile }
58
58
59
59
deleteAndSetupTestAccount ()
You can’t perform that action at this time.
0 commit comments