diff --git a/test.env b/test.env new file mode 100644 index 00000000..0a385dbd --- /dev/null +++ b/test.env @@ -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 diff --git a/tests/authentication.rs b/tests/authentication.rs index 1c920e98..32e62a88 100644 --- a/tests/authentication.rs +++ b/tests/authentication.rs @@ -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() diff --git a/tests/chart.rs b/tests/chart.rs index 39a782e1..43fc839e 100644 --- a/tests/chart.rs +++ b/tests/chart.rs @@ -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() diff --git a/tests/voting.rs b/tests/voting.rs index 25fa6863..677c27a6 100644 --- a/tests/voting.rs +++ b/tests/voting.rs @@ -16,26 +16,14 @@ struct AuthenticatedUser { token: String, } -#[derive(Debug, Default, Copy, Clone, Parameter)] +#[derive(Debug, Default, Copy, Clone, Parameter, strum::EnumString)] #[param(name = "vote-type", regex = "upvote|downvote")] +#[strum(ascii_case_insensitive)] enum VoteType { #[default] Upvote, Downvote, } - -impl FromStr for VoteType { - type Err = String; - - fn from_str(s: &str) -> Result { - Ok(match s { - "upvote" => Self::Upvote, - "downvote" => Self::Downvote, - _ => return Err(format!("invalid vote type {s}")), - }) - } -} - impl From for bool { fn from(value: VoteType) -> Self { match value { @@ -265,6 +253,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()