Skip to content

Add initial database connection logic

João Pereira requested to merge db-connection into database

This MR implements the initial DB connection logic and integrated tests.

PostgreSQL

PostgreSQL is used for the database. For now, a database should be manually created (only once) in each development environment. See the docs for guidance.

Later on we may opt for spinning an ephemeral PostgreSQL Docker container from within the test suite but this should be a separate improvement.

For GitLab CI we just added a new service and use it to run the integration tests.

Go Dependencies

This MR introduces two new dependencies:

These dependencies are in line with our Go development guidelines.

New Conventions

Now that we're starting to write a completely new piece of the registry, we should strive to adopt best practices and even create our own if necessary. In this MR I have adopted some practices that are commonly advised by the community. I would like to discuss and possibly see them being adopted from now on.

Unit tests

It's a good idea to place the tests in a separate package (i.e. place tests for the x package in x_test). This makes sure that we focus on testing only the exported API for each package and stop relying on its internal functions as test helpers, etc.

If we really need to test some internal functions, we could create a separate test file, e.g. *_internal_test.go and test it there.

Integration tests

I placed the integrated tests in a separate file, e.g. *_integration_test.go. This allows us to separate integration tests and run them with go test -tags=integration.

This is part of &2313 (closed) and related to #56 (closed).

Edited by João Pereira

Merge request reports

Loading