Skip to content

Commit

Permalink
chore: update test-context dependency (#1665)
Browse files Browse the repository at this point in the history
* chore: update test-context dependency

* fix: don't use async_trait for AsyncTestContext implementations
  • Loading branch information
JasterV committed Mar 6, 2024
1 parent 83d9651 commit d39724a
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 15 deletions.
31 changes: 26 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Expand Up @@ -89,7 +89,7 @@ strfmt = "0.2.2"
strum = { version = "0.25.0", features = ["derive"] }
tar = "0.4.38"
tempfile = "3.4.0"
test-context = "0.1.4"
test-context = "0.3.0"
thiserror = "1.0.37"
tokio = "1.22.0"
tokio-stream = "0.1.11"
Expand Down
4 changes: 1 addition & 3 deletions common/src/backends/client/gateway.rs
Expand Up @@ -114,23 +114,21 @@ impl ProjectsDal for Client {

#[cfg(test)]
mod tests {
use async_trait::async_trait;
use test_context::{test_context, AsyncTestContext};

use crate::models::project::{Response, State};
use crate::test_utils::get_mocked_gateway_server;

use super::{Client, ProjectsDal};

#[async_trait]
impl AsyncTestContext for Client {
async fn setup() -> Self {
let server = get_mocked_gateway_server().await;

Client::new(server.uri().parse().unwrap(), server.uri().parse().unwrap())
}

async fn teardown(mut self) {}
async fn teardown(self) {}
}

#[test_context(Client)]
Expand Down
4 changes: 1 addition & 3 deletions gateway/src/lib.rs
Expand Up @@ -884,7 +884,6 @@ pub mod tests {
}
}

#[async_trait]
impl AsyncTestContext for TestGateway {
async fn setup() -> Self {
let world = World::new().await;
Expand All @@ -903,7 +902,7 @@ pub mod tests {
}
}

async fn teardown(mut self) {}
async fn teardown(self) {}
}

/// Helper struct to wrap a bunch of commands to run against a test project
Expand Down Expand Up @@ -1159,7 +1158,6 @@ pub mod tests {
}
}

#[async_trait]
impl AsyncTestContext for TestProject {
async fn setup() -> Self {
let mut world = TestGateway::setup().await;
Expand Down
4 changes: 1 addition & 3 deletions proto/src/lib.rs
Expand Up @@ -305,7 +305,6 @@ mod _resource_recorder_client {

#[cfg(test)]
mod tests {
use async_trait::async_trait;
use serde_json::json;
use shuttle_common::{database, resource};
use test_context::{test_context, AsyncTestContext};
Expand All @@ -316,15 +315,14 @@ mod _resource_recorder_client {

use super::{get_client, Client, ResourceDal};

#[async_trait]
impl AsyncTestContext for Client {
async fn setup() -> Self {
let port = get_mocked_resource_recorder().await;

get_client(format!("http://localhost:{port}").parse().unwrap()).await
}

async fn teardown(mut self) {}
async fn teardown(self) {}
}

#[test_context(Client)]
Expand Down

0 comments on commit d39724a

Please sign in to comment.