Skip to content

Commit

Permalink
test(integration): generate consistent dates
Browse files Browse the repository at this point in the history
A test started to fail as it used a reference image containing a generated date, which is only valid for runs on that date. Until today, runs must not have produced enough pixel differences to fail.

This change uses libfaketime to change the system date so that generated dates are always the same. I'm using the 'start at' option ('@') to see time differences in the logs (it's always midnight otherwise). I'm not aware of anywhere in the app that displays times, so this shouldn't be a problem.

The date I've chosen is the one that appears in the failing test, solely to avoid regenerating those images.

Refs ccde93a
  • Loading branch information
thewilkybarkid committed Oct 11, 2021
1 parent ccde93a commit 54be830
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ CMD ["start:dev"]
FROM dev AS integration
ENV NODE_ENV=integration

COPY --from=trajano/alpine-libfaketime /faketime.so /lib/faketime.so
ENV LD_PRELOAD=/lib/faketime.so
ENV DONT_FAKE_MONOTONIC=1

COPY --from=backend /app/src/ src/
COPY --from=frontend /app/dist/frontend/ dist/frontend/

Expand Down
1 change: 1 addition & 0 deletions docker-compose.integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ services:
build:
target: integration
environment:
FAKETIME: '@2021-10-01 00:00:00'
PREREVIEW_ADMIN_USERS: '0000-0002-6266-406X'
PREREVIEW_ORCID_CALLBACK_URL: 'http://prereview:3000/api/v2/orcid/callback'
TEST_ADMIN_USER_ORCID: '0000-0002-6266-406X'
Expand Down

0 comments on commit 54be830

Please sign in to comment.