Skip to content

Commit

Permalink
test: Add integration tests for Indexer (#627)
Browse files Browse the repository at this point in the history
This PR adds a very basic integration test for `Indexer`. It uses
`testcontainers` to stand up both `postgres` and `hasura` so that
`Indexer` can talk to real components rather than mocks. The test uses
`Indexer` directly, which means S3/Redis are still somewhat
mocked/ignored. We can add those in later if need be.

This is essentially just the scaffolding for integration testing which
can be expanded over time. The suite includes only 1 very basic test,
which if successful should provide a fair amount of confidence that
things are working as expected. The flow includes: provisioning, writing
data to Postgres, and then asserting its existence via GraphQL. All
errors bubble up from `Indexer` so this test should catch most problems.

This PR points to #625, as so I
could test the `pg_cron` flow via this integration test :)
  • Loading branch information
morgsmccauley authored Mar 29, 2024
1 parent 738ad09 commit b7d43e1
Show file tree
Hide file tree
Showing 21 changed files with 39,492 additions and 115 deletions.
9 changes: 9 additions & 0 deletions hasura/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM hasura/graphql-engine:latest.cli-migrations-v3

ARG DATABASE_URL
ARG PORT

COPY migrations /hasura-migrations
COPY metadata /hasura-metadata

CMD graphql-engine serve
11 changes: 11 additions & 0 deletions postgres.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM postgres:14

RUN apt-get update && apt-get install -y postgresql-14-cron

RUN echo "shared_preload_libraries = 'pg_cron'" >> /usr/share/postgresql/postgresql.conf.sample

RUN echo "CREATE EXTENSION pg_cron;" > /docker-entrypoint-initdb.d/init-pg-cron.sql

EXPOSE 5432

CMD ["postgres"]
2 changes: 1 addition & 1 deletion runner/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = {
},
},
{
files: ['./src/**/*'],
files: ['./src/**/*', './tests/**/*'],
parserOptions: {
project: './tsconfig.json',
},
Expand Down
3 changes: 2 additions & 1 deletion runner/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node'
testEnvironment: 'node',
roots: ['./src', './tests'],
};
Loading

0 comments on commit b7d43e1

Please sign in to comment.