Skip to content

Commit

Permalink
factor out a method from a test
Browse files Browse the repository at this point in the history
  • Loading branch information
imor committed Aug 21, 2024
1 parent 0f5d39f commit dae863b
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions api/tests/api/sources.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use api::db::sources::SourceConfig;

use crate::test_app::{
spawn_app, CreateSourceRequest, CreateSourceResponse, CreateTenantRequest, CreateTenantResponse,
spawn_app, CreateSourceRequest, CreateSourceResponse, CreateTenantRequest,
CreateTenantResponse, TestApp,
};

fn new_source_config() -> SourceConfig {
Expand All @@ -16,10 +17,7 @@ fn new_source_config() -> SourceConfig {
}
}

#[tokio::test]
async fn source_can_be_created() {
// Arrange
let app = spawn_app().await;
async fn create_tenant(app: &TestApp) -> i64 {
let tenant = CreateTenantRequest {
name: "NewTenant".to_string(),
supabase_project_ref: None,
Expand All @@ -29,7 +27,14 @@ async fn source_can_be_created() {
.json()
.await
.expect("failed to deserialize response");
let tenant_id = response.id;
response.id
}

#[tokio::test]
async fn source_can_be_created() {
// Arrange
let app = spawn_app().await;
let tenant_id = create_tenant(&app).await;

// Act
let source = CreateSourceRequest {
Expand Down

0 comments on commit dae863b

Please sign in to comment.