Skip to content
This repository was archived by the owner on Sep 2, 2024. It is now read-only.

Commit ea80e11

Browse files
committed
fixed all tests, added GH workflows
1 parent 80c8135 commit ea80e11

File tree

7 files changed

+35
-19
lines changed

7 files changed

+35
-19
lines changed

.github/workflows/go.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ deploy: build
1212
scp -qr ./templates/* sb-poc:/home/dstpierre/templates/
1313

1414
alltest:
15-
@JWT_SECRET=okdevmode go test --race --cover $(go list ./... | grep -v /postgres-data/)
15+
@JWT_SECRET=okdevmode go test --race --cover ./...
1616

1717
test-pg:
1818
@JWT_SECRET=okdevmode go test --race --cover ./database/postgresql

database/mongo/function.go

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

1313
type LocalExecData struct {
1414
ID primitive.ObjectID `bson:"_id" json:"id"`
15-
AccountID primitive.ObjectID `bson:"accountId" json:"accountId"`
1615
FunctionName string `bson:"name" json:"name"`
1716
TriggerTopic string `bson:"tr" json:"trigger"`
1817
Code string `bson:"code" json:"code"`
@@ -38,15 +37,8 @@ func toLocalExecData(ex internal.ExecData) LocalExecData {
3837
return LocalExecData{}
3938
}
4039

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-
4740
return LocalExecData{
4841
ID: oid,
49-
AccountID: aid,
5042
FunctionName: ex.FunctionName,
5143
TriggerTopic: ex.TriggerTopic,
5244
Code: ex.Code,
@@ -77,7 +69,6 @@ func toLocalExecHistory(h []internal.ExecHistory) []LocalExecHistory {
7769
func fromLocalExecData(lex LocalExecData) internal.ExecData {
7870
return internal.ExecData{
7971
ID: lex.ID.Hex(),
80-
AccountID: lex.AccountID.Hex(),
8172
FunctionName: lex.FunctionName,
8273
TriggerTopic: lex.TriggerTopic,
8374
Code: lex.Code,

docker-compose-mongo.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ services:
44
mongo:
55
image: mongo:3-stretch
66
volumes:
7-
- ./mongodata:/data/db/mongo
7+
- ../mongodata:/data/db/mongo
88
ports:
99
- "27017:27017"
1010

docker-compose-unittest.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,10 @@ services:
1010
- POSTGRES_USER=postgres
1111
- POSTGRES_PASSWORD=postgres
1212
volumes:
13-
- ./postgres-data:/var/lib/postgresql/data
1413
- ./sql/0001_bootstrap_db.sql:/docker-entrypoint-initdb.d/create_tables.sql
1514

1615
mongo:
1716
image: mongo:3-stretch
18-
volumes:
19-
- ./mongodata:/data/db/mongo
2017
ports:
2118
- "27017:27017"
2219

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ services:
1010
- POSTGRES_USER=postgres
1111
- POSTGRES_PASSWORD=postgres
1212
volumes:
13-
- ./postgres-data:/var/lib/postgresql/data
13+
- ../postgres-data:/var/lib/postgresql/data
1414
- ./sql/0001_bootstrap_db.sql:/docker-entrypoint-initdb.d/create_tables.sql
1515

1616
redis:

main_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,24 +36,24 @@ var (
3636
)
3737

3838
func TestMain(m *testing.M) {
39+
volatile = cache.NewCache()
40+
3941
if strings.EqualFold(os.Getenv("DATA_STORE"), "mongo") {
4042
cl, err := openMongoDatabase("mongodb://localhost:27017")
4143
if err != nil {
4244
log.Fatal(err)
4345
}
4446

45-
datastore = mongo.New(cl)
47+
datastore = mongo.New(cl, volatile.PublishDocument)
4648
} else {
4749
dbConn, err := openPGDatabase("user=postgres password=postgres dbname=postgres sslmode=disable")
4850
if err != nil {
4951
log.Fatal(err)
5052
}
5153

52-
datastore = postgresql.New(dbConn)
54+
datastore = postgresql.New(dbConn, volatile.PublishDocument)
5355
}
5456

55-
volatile = cache.NewCache()
56-
5757
database = &Database{cache: volatile}
5858

5959
deleteAndSetupTestAccount()

0 commit comments

Comments
 (0)