Skip to content

Commit e21dc4a

Browse files
authored
fix e2e tests (#111)
1 parent 0310c6c commit e21dc4a

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
dist: focal
12
language: go
23
go:
34
- 1.21.x

_script/run-e2e.sh

+5-9
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ case $# in
1616
;;
1717
esac
1818

19-
COMPOSE_OPTIONS=""
2019
case $ARG in
2120
"read")
2221
CONFIG_FILE="_resources/config/e2e-read-replica.toml"
@@ -34,17 +33,15 @@ case $ARG in
3433
;;
3534
esac
3635

37-
3836
# Start postgress databases.
39-
docker-compose -f _resources/docker-compose-e2e.yml -p "e2e" up -d $SERVICE
37+
docker-compose -f _resources/docker-compose-e2e.yml -p e2e up --quiet-pull -d $SERVICE
4038

4139
# Set up schema for the test db.
42-
set +e
43-
rm -rf /tmp/vulnerability-db
44-
set -e
45-
git clone --single-branch --branch master https://github.com/adevinta/vulnerability-db.git /tmp/vulnerability-db
46-
docker run --net=host -v /tmp/vulnerability-db/db:/flyway/sql flyway/flyway:"${FLYWAY_VERSION:-8}-alpine" \
40+
VDB=$(mktemp -d)
41+
git clone --single-branch --branch master https://github.com/adevinta/vulnerability-db.git "$VDB"
42+
docker run --net=host -v "$VDB/db/sql":/flyway/sql flyway/flyway:"${FLYWAY_VERSION:-10}-alpine" \
4743
-user=vulndb -password=vulndb -url=jdbc:postgresql://127.0.0.1:5434/vulndbtest -baselineOnMigrate=true migrate
44+
rm -rf "$VDB"
4845

4946
# Loaf fixtures in the test db.
5047
TestDBPort=5434 go run e2e/fixtures.go _resources/e2e/fixtures/
@@ -70,4 +67,3 @@ set +e
7067
pkill vulnerability-db-api
7168
set -e
7269
docker-compose -f _resources/docker-compose-e2e.yml -p "e2e" rm -s -f -v
73-

e2e/fixtures.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func LoadFixtures(fixturesDir string) error {
4848
defer db.Close() // nolint: errcheck
4949

5050
// Mock current time to ensure consistent exposure calculations.
51-
_, err = db.Exec(`CREATE SCHEMA mock;`)
51+
_, err = db.Exec(`CREATE SCHEMA IF NOT EXISTS mock;`)
5252
if err != nil {
5353
return err
5454
}

0 commit comments

Comments
 (0)