Skip to content

Commit

Permalink
feat: auto-load .env in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Zoe Spellman committed Feb 21, 2024
1 parent 734f3f4 commit 50475a0
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
17 changes: 17 additions & 0 deletions test.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
APP_ENV=dev
APP_HOST=0.0.0.0
APP_JWT_SECRET=deadbeef
APP_LOG_LEVEL=info
APP_NAME=ratings
APP_PORT=8080
# Update this with some real PostgreSQL details
APP_POSTGRES_URI=postgresql://migration_user:strongpassword@localhost:5433/ratings
APP_MIGRATION_POSTGRES_URI=postgresql://migration_user:strongpassword@localhost:5433/ratings

DOCKER_POSTGRES_USER=postgres
DOCKER_POSTGRES_PASSWORD=@1234
DOCKER_MIGRATION_USER=migration_user
DOCKER_MIGRATION_PASSWORD=strongpassword
DOCKER_SERVICE_USER=service
DOCKER_SERVICE_PASSWORD=covfefe!1
DOCKER_RATINGS_DB=ratings
2 changes: 2 additions & 0 deletions tests/authentication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ async fn no_double_auth(world: &mut AuthenticationWorld) {

#[tokio::main]
async fn main() {
dotenv::from_filename("test.env").ok();

AuthenticationWorld::cucumber()
.repeat_skipped()
.init_tracing()
Expand Down
2 changes: 2 additions & 0 deletions tests/chart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,8 @@ async fn clear_db() {

#[tokio::main]
async fn main() {
dotenv::from_filename("test.env").ok();

ChartWorld::cucumber()
.before(|_, _, _, _| clear_db().boxed_local())
.repeat_failed()
Expand Down
4 changes: 3 additions & 1 deletion tests/voting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ struct AuthenticatedUser {
token: String,
}

#[derive(Debug, Default, Copy, Clone, Parameter)]
#[derive(Debug, Default, Copy, Clone, Parameter, strum::)]
#[param(name = "vote-type", regex = "upvote|downvote")]
enum VoteType {
#[default]
Expand Down Expand Up @@ -265,6 +265,8 @@ async fn check_upvote(world: &mut VotingWorld, direction: Direction) {

#[tokio::main]
async fn main() {
dotenv::from_filename("test.env").ok();

VotingWorld::cucumber()
.repeat_skipped()
.init_tracing()
Expand Down

0 comments on commit 50475a0

Please sign in to comment.