From 2fda6569f3b0285345eaa8169834b11060c7a4db Mon Sep 17 00:00:00 2001 From: Nick Gerace Date: Thu, 6 Jun 2024 18:31:39 -0400 Subject: [PATCH] Enhance dal-test helpers and schemas This commit aims to enhance dal-test helpers and test exclusive schemas. As a result of these changes, panics of any kind are banned by default outside of macro expansion helpers. Now, when authoring test exclusive schemas or authoring tests, error reporting should be clearer than before. For the helpers, we leverage "color_eyre" via its "Result" type and "eyre!" macro in order to make error propagation better in tests via explicit "expect" statements and other failures. Inner panics are now disallowed in helpers themselves in order to give better error location reporting when running tests via buck2 with default settings. For the test exclusive schemas, everything has been refactored to be more explicit about how schemas are organized and where migrations are centralized. These changes reflect the shape of the schemas back in the old engine when they were in the dal. In addition to these changes, the helpers for test exclusive schemas have been polished, including some unnecessary usages of async functions and replaced panics. These helpers have been moved to the central module file and now, the only public, exported function is the "migrate" function. Finally, panics within test exclusive schema scaffolding have also been replaced with proper error propagation. As a result of these changes, both "DalTestHelpersError" and "ChangeSetTestHelpers" have been removed alongside their result types. Secondary changes: - Fix swallowed errors when setting types in frame integration tests - Split property editor test view into its own submodule - Move auth token creation into expand helpers (moved from the regular test helpers) - Temporarily disable "delete_frame_with_child_with_resource" test due to intermittent failures Signed-off-by: Nick Gerace --- lib/dal-test/src/expand_helpers.rs | 25 +- lib/dal-test/src/helpers.rs | 370 ++++------------ lib/dal-test/src/helpers/change_set.rs | 94 +--- .../src/helpers/property_editor_test_view.rs | 149 +++++++ lib/dal-test/src/lib.rs | 97 +---- lib/dal-test/src/schemas/mod.rs | 31 -- lib/dal-test/src/schemas/schema_helpers.rs | 101 ----- .../test_exclusive_lego_schemas/mod.rs | 11 - .../category_pirate.rs} | 29 +- .../category_validated.rs} | 28 +- .../dummy_secret.rs} | 9 +- .../fallout.rs} | 15 +- .../katy_perry.rs} | 28 +- .../legos}/bricks.rs | 2 +- .../legos/large.rs} | 35 +- .../legos/medium.rs} | 35 +- .../src/test_exclusive_schemas/legos/mod.rs | 11 + .../legos/small.rs} | 35 +- .../src/test_exclusive_schemas/mod.rs | 160 +++++++ .../starfield.rs} | 80 ++-- .../swifty.rs} | 25 +- lib/dal/examples/snapshot-analyzer/main.rs | 12 +- lib/dal/tests/integration_test/action.rs | 28 +- lib/dal/tests/integration_test/component.rs | 50 ++- .../tests/integration_test/component/debug.rs | 5 +- .../integration_test/component/get_code.rs | 12 +- .../integration_test/component/get_diff.rs | 12 +- .../integration_test/component/set_type.rs | 4 +- .../integration_test/component/upgrade.rs | 4 +- lib/dal/tests/integration_test/connection.rs | 43 +- lib/dal/tests/integration_test/frame.rs | 409 +++++++++++++----- .../integration_test/frame/omega_nesting.rs | 24 +- .../integration_test/frame/with_actions.rs | 16 +- .../func/authoring/test_execute.rs | 20 +- .../tests/integration_test/property_editor.rs | 58 ++- .../tests/integration_test/qualifications.rs | 3 +- lib/dal/tests/integration_test/rebaser.rs | 51 ++- .../tests/integration_test/schema/variant.rs | 6 +- .../variant/authoring/update_variant.rs | 8 +- lib/dal/tests/integration_test/secret.rs | 31 +- .../integration_test/secret/with_actions.rs | 13 +- lib/dal/tests/integration_test/validations.rs | 63 ++- lib/dal/tests/integration_test/workspace.rs | 6 +- 43 files changed, 1218 insertions(+), 1030 deletions(-) create mode 100644 lib/dal-test/src/helpers/property_editor_test_view.rs delete mode 100644 lib/dal-test/src/schemas/mod.rs delete mode 100644 lib/dal-test/src/schemas/schema_helpers.rs delete mode 100644 lib/dal-test/src/schemas/test_exclusive_lego_schemas/mod.rs rename lib/dal-test/src/{schemas/test_exclusive_schema_category_pirate.rs => test_exclusive_schemas/category_pirate.rs} (90%) rename lib/dal-test/src/{schemas/test_exclusive_schema_category_validated.rs => test_exclusive_schemas/category_validated.rs} (93%) rename lib/dal-test/src/{schemas/test_exclusive_schema_dummy_secret.rs => test_exclusive_schemas/dummy_secret.rs} (97%) rename lib/dal-test/src/{schemas/test_exclusive_schema_fallout.rs => test_exclusive_schemas/fallout.rs} (96%) rename lib/dal-test/src/{schemas/test_exclusive_schema_katy_perry.rs => test_exclusive_schemas/katy_perry.rs} (88%) rename lib/dal-test/src/{schemas/test_exclusive_lego_schemas => test_exclusive_schemas/legos}/bricks.rs (99%) rename lib/dal-test/src/{schemas/test_exclusive_lego_schemas/test_exclusive_schema_lego_large.rs => test_exclusive_schemas/legos/large.rs} (92%) rename lib/dal-test/src/{schemas/test_exclusive_lego_schemas/test_exclusive_schema_lego_medium.rs => test_exclusive_schemas/legos/medium.rs} (91%) create mode 100644 lib/dal-test/src/test_exclusive_schemas/legos/mod.rs rename lib/dal-test/src/{schemas/test_exclusive_lego_schemas/test_exclusive_schema_lego_small.rs => test_exclusive_schemas/legos/small.rs} (91%) create mode 100644 lib/dal-test/src/test_exclusive_schemas/mod.rs rename lib/dal-test/src/{schemas/test_exclusive_schema_starfield.rs => test_exclusive_schemas/starfield.rs} (93%) rename lib/dal-test/src/{schemas/test_exclusive_schema_swifty.rs => test_exclusive_schemas/swifty.rs} (94%) diff --git a/lib/dal-test/src/expand_helpers.rs b/lib/dal-test/src/expand_helpers.rs index 1022c59356..f624d0e8e4 100644 --- a/lib/dal-test/src/expand_helpers.rs +++ b/lib/dal-test/src/expand_helpers.rs @@ -4,12 +4,12 @@ //! macro expansion. use dal::{ChangeSet, ChangeSetId, DalContext, UserClaim}; +use jwt_simple::algorithms::RSAKeyPairLike; +use jwt_simple::claims::Claims; +use jwt_simple::prelude::Duration; use tracing_subscriber::{fmt, util::SubscriberInitExt, EnvFilter, Registry}; -use crate::{ - helpers::{create_auth_token, generate_fake_name}, - WorkspaceSignup, -}; +use crate::{helpers::generate_fake_name, jwt_private_signing_key, WorkspaceSignup}; /// This function is used during macro expansion for setting up a [`ChangeSet`] in an integration test. pub async fn create_change_set_and_update_ctx( @@ -25,7 +25,7 @@ pub async fn create_change_set_and_update_ctx( .expect("no workspace snapshot set on base change set"); let change_set = ChangeSet::new( ctx, - generate_fake_name(), + generate_fake_name().expect("could not generate fake name"), Some(base_change_set_id), workspace_snapshot_address, ) @@ -142,7 +142,7 @@ pub async fn workspace_signup(ctx: &DalContext) -> crate::Result<(WorkspaceSignu let mut ctx = ctx.clone_with_head().await?; - let workspace_name = generate_fake_name(); + let workspace_name = generate_fake_name().expect("could not generate fake name"); let user_name = format!("frank {workspace_name}"); let user_email = format!("{workspace_name}@example.com"); @@ -153,6 +153,17 @@ pub async fn workspace_signup(ctx: &DalContext) -> crate::Result<(WorkspaceSignu user_pk: nw.user.pk(), workspace_pk: *nw.workspace.pk(), }) - .await; + .await + .expect("could not create auth token"); Ok((nw, auth_token)) } + +async fn create_auth_token(claim: UserClaim) -> crate::Result { + let key_pair = jwt_private_signing_key().await?; + let claim = Claims::with_custom_claims(claim, Duration::from_days(1)) + .with_audience("https://app.systeminit.com") + .with_issuer("https://app.systeminit.com") + .with_subject(claim.user_pk); + + Ok(key_pair.sign(claim).expect("could not sign")) +} diff --git a/lib/dal-test/src/helpers.rs b/lib/dal-test/src/helpers.rs index 1936b6361f..35ec3f1bdc 100644 --- a/lib/dal-test/src/helpers.rs +++ b/lib/dal-test/src/helpers.rs @@ -1,102 +1,59 @@ //! This module contains helpers for use when authoring dal integration tests. -use async_recursion::async_recursion; -use dal::attribute::value::AttributeValueError; +use color_eyre::eyre::eyre; +use color_eyre::Result; use dal::key_pair::KeyPairPk; -use dal::property_editor::schema::{ - PropertyEditorProp, PropertyEditorPropKind, PropertyEditorSchema, -}; -use dal::property_editor::values::{PropertyEditorValue, PropertyEditorValues}; -use dal::property_editor::{PropertyEditorPropId, PropertyEditorValueId}; use dal::{ - AttributeValue, Component, ComponentError, ComponentId, DalContext, InputSocket, KeyPair, - OutputSocket, Prop, Schema, SchemaVariant, SchemaVariantId, User, UserClaim, UserPk, + AttributeValue, Component, ComponentId, DalContext, InputSocket, KeyPair, OutputSocket, Schema, + SchemaVariant, SchemaVariantId, User, UserPk, }; -use itertools::enumerate; -use jwt_simple::algorithms::RSAKeyPairLike; -use jwt_simple::{claims::Claims, reexports::coarsetime::Duration}; use names::{Generator, Name}; -use serde::{Deserialize, Serialize}; -use serde_json::Value; -use std::collections::HashMap; -use thiserror::Error; - -use crate::jwt_private_signing_key; mod change_set; +mod property_editor_test_view; pub use change_set::ChangeSetTestHelpers; -pub use change_set::ChangeSetTestHelpersError; - -#[allow(missing_docs)] -#[derive(Debug, Error)] -pub enum DalTestHelpersError { - #[error("attribute value error: {0}")] - AttributeValue(#[from] AttributeValueError), - #[error("component error: {0}")] - Component(#[from] ComponentError), - #[error("too many attribute values found")] - TooManyAttributeValues, - #[error("unexpected empty attribute values found")] - UnexpectedEmptyAttributeValues, -} - -type DalTestHelpersResult = Result; +pub use property_editor_test_view::PropEditorTestView; /// Generates a fake name. -pub fn generate_fake_name() -> String { +pub fn generate_fake_name() -> Result { Generator::with_naming(Name::Numbered) .next() - .expect("could not generate fake name") -} - -/// Creates an auth token. -pub async fn create_auth_token(claim: UserClaim) -> String { - let key_pair = jwt_private_signing_key() - .await - .expect("failed to load jwt private signing key"); - let claim = Claims::with_custom_claims(claim, Duration::from_days(1)) - .with_audience("https://app.systeminit.com") - .with_issuer("https://app.systeminit.com") - .with_subject(claim.user_pk); - - key_pair.sign(claim).expect("unable to sign jwt") + .ok_or(eyre!("could not generate fake name")) } /// Creates a connection annotation string. +#[allow(clippy::expect_used)] #[macro_export] macro_rules! connection_annotation_string { ($str:expr) => { - serde_json::to_string(&vec![$str]).expect("Unable to parse annotation string") + serde_json::to_string(&vec![$str]).expect("unable to parse annotation string") }; } /// Creates a dummy key pair. -pub async fn create_key_pair(ctx: &DalContext) -> KeyPair { - let name = generate_fake_name(); - KeyPair::new(ctx, &name) - .await - .expect("cannot create key pair") +pub async fn create_key_pair(ctx: &DalContext) -> Result { + let name = generate_fake_name()?; + Ok(KeyPair::new(ctx, &name).await?) } /// Creates a dummy user. -pub async fn create_user(ctx: &DalContext) -> User { - let name = generate_fake_name(); - User::new( +pub async fn create_user(ctx: &DalContext) -> Result { + let name = generate_fake_name()?; + Ok(User::new( ctx, UserPk::generate(), &name, &format!("{name}@test.systeminit.com"), None::<&str>, ) - .await - .expect("cannot create user") + .await?) } /// Creates a dummy schema. -pub async fn create_schema(ctx: &DalContext) -> Schema { - let name = generate_fake_name(); - Schema::new(ctx, &name).await.expect("cannot create schema") +pub async fn create_schema(ctx: &DalContext) -> Result { + let name = generate_fake_name()?; + Ok(Schema::new(ctx, &name).await?) } /// Creates a [`Component`] from the default [`SchemaVariant`] corresponding to a provided @@ -105,31 +62,21 @@ pub async fn create_component_for_schema_name( ctx: &DalContext, schema_name: impl AsRef, name: impl AsRef, -) -> Component { +) -> Result { let schema = Schema::find_by_name(ctx, schema_name) - .await - .expect("could not find schema") - .expect("schema not found"); - let schema_variant = SchemaVariant::list_for_schema(ctx, schema.id()) - .await - .expect("failed listing schema variants") - .pop() - .expect("no schema variant found"); - - Component::new(ctx, name.as_ref().to_string(), schema_variant.id()) - .await - .expect("could not create component") + .await? + .ok_or(eyre!("schema not found"))?; + let schema_variant_id = SchemaVariant::get_default_id_for_schema(ctx, schema.id()).await?; + Ok(Component::new(ctx, name.as_ref().to_string(), schema_variant_id).await?) } /// Creates a [`Component`] for a given [`SchemaVariantId`](SchemaVariant). pub async fn create_component_for_schema_variant( ctx: &DalContext, schema_variant_id: SchemaVariantId, -) -> Component { - let name = generate_fake_name(); - Component::new(ctx, &name, schema_variant_id) - .await - .expect("cannot create component") +) -> Result { + let name = generate_fake_name()?; + Ok(Component::new(ctx, &name, schema_variant_id).await?) } /// Connects two [`Components`](Component) for a given set of socket names. @@ -139,28 +86,20 @@ pub async fn connect_components_with_socket_names( output_socket_name: impl AsRef, destination_component_id: ComponentId, input_socket_name: impl AsRef, -) { +) -> Result<()> { let from_socket_id = { - let sv_id = Component::schema_variant_id(ctx, source_component_id) - .await - .expect("find schema variant for source component"); - + let sv_id = Component::schema_variant_id(ctx, source_component_id).await?; OutputSocket::find_with_name(ctx, output_socket_name, sv_id) - .await - .expect("perform find output socket") - .expect("find output socket") + .await? + .ok_or(eyre!("no output socket found"))? .id() }; let to_socket_id = { - let sv_id = Component::schema_variant_id(ctx, destination_component_id) - .await - .expect("find schema variant for destination component"); - + let sv_id = Component::schema_variant_id(ctx, destination_component_id).await?; InputSocket::find_with_name(ctx, input_socket_name, sv_id) - .await - .expect("perform find input socket") - .expect("find input socket") + .await? + .ok_or(eyre!("no input socket found"))? .id() }; @@ -171,8 +110,8 @@ pub async fn connect_components_with_socket_names( destination_component_id, to_socket_id, ) - .await - .expect("could not connect components"); + .await?; + Ok(()) } /// Gets the [`Value`] for a specific [`Component`]'s [`InputSocket`] by the [`InputSocket`] name @@ -180,28 +119,19 @@ pub async fn get_component_input_socket_value( ctx: &DalContext, component_id: ComponentId, input_socket_name: impl AsRef, -) -> Option { - let schema_variant_id = Component::schema_variant_id(ctx, component_id) - .await - .expect("got schema variant id"); - let component = Component::get_by_id(ctx, component_id) - .await - .expect("got component"); - let component_input_sockets = component - .input_socket_attribute_values(ctx) - .await - .expect("got attribute values"); +) -> Result> { + let schema_variant_id = Component::schema_variant_id(ctx, component_id).await?; + let component = Component::get_by_id(ctx, component_id).await?; + let component_input_sockets = component.input_socket_attribute_values(ctx).await?; let input_socket = InputSocket::find_with_name(ctx, input_socket_name, schema_variant_id) - .await - .expect("got input socket") - .expect("has value"); + .await? + .ok_or(eyre!("no input socket found"))?; let input_socket_match = component_input_sockets .get(&input_socket.id()) - .expect("got input socket av"); - let input_socket_av = AttributeValue::get_by_id(ctx, input_socket_match.attribute_value_id) - .await - .expect("got input av"); - input_socket_av.view(ctx).await.expect("got view") + .ok_or(eyre!("no input socket match found"))?; + let input_socket_av = + AttributeValue::get_by_id(ctx, input_socket_match.attribute_value_id).await?; + Ok(input_socket_av.view(ctx).await?) } /// Gets the [`Value`] for a specific [`Component`]'s [`OutputSocket`] by the [`OutputSocket`] name @@ -209,28 +139,19 @@ pub async fn get_component_output_socket_value( ctx: &DalContext, component_id: ComponentId, output_socket_name: impl AsRef, -) -> Option { - let schema_variant_id = Component::schema_variant_id(ctx, component_id) - .await - .expect("got schema variant id"); - let component = Component::get_by_id(ctx, component_id) - .await - .expect("got component"); - let component_output_sockets = component - .output_socket_attribute_values(ctx) - .await - .expect("got attribute values"); +) -> Result> { + let schema_variant_id = Component::schema_variant_id(ctx, component_id).await?; + let component = Component::get_by_id(ctx, component_id).await?; + let component_output_sockets = component.output_socket_attribute_values(ctx).await?; let output_socket = OutputSocket::find_with_name(ctx, output_socket_name, schema_variant_id) - .await - .expect("got output socket") - .expect("has value"); + .await? + .ok_or(eyre!("no output socket found"))?; let output_socket_match = component_output_sockets .get(&output_socket.id()) - .expect("got output socket av"); - let output_socket_av = AttributeValue::get_by_id(ctx, output_socket_match.attribute_value_id) - .await - .expect("got output av"); - output_socket_av.view(ctx).await.expect("got view") + .ok_or(eyre!("no output socket match found"))?; + let output_socket_av = + AttributeValue::get_by_id(ctx, output_socket_match.attribute_value_id).await?; + Ok(output_socket_av.view(ctx).await?) } /// Update the [`Value`] for a specific [`AttributeValue`] for the given [`Component`](ComponentId) by the [`PropPath`] pub async fn update_attribute_value_for_component( @@ -238,20 +159,17 @@ pub async fn update_attribute_value_for_component( component_id: ComponentId, prop_path: &[&str], value: serde_json::Value, -) { - let component = Component::get_by_id(ctx, component_id) - .await - .expect("got component"); - let attribute_value_id = component - .attribute_values_for_prop(ctx, prop_path) - .await - .expect("found attribute values for prop") - .into_iter() - .next() - .expect("got attribute value id"); - AttributeValue::update(ctx, attribute_value_id, Some(value)) - .await - .expect("updated attribute value"); +) -> Result<()> { + let component = Component::get_by_id(ctx, component_id).await?; + let mut attribute_value_ids = component.attribute_values_for_prop(ctx, prop_path).await?; + let attribute_value_id = attribute_value_ids + .pop() + .ok_or(eyre!("unexpected: no attribute values found"))?; + if !attribute_value_ids.is_empty() { + return Err(eyre!("unexpected: more than one attribute value found")); + } + AttributeValue::update(ctx, attribute_value_id, Some(value)).await?; + Ok(()) } /// Encrypts a message with a given [`KeyPairPk`](KeyPair). @@ -259,23 +177,21 @@ pub async fn encrypt_message( ctx: &DalContext, key_pair_pk: KeyPairPk, message: &serde_json::Value, -) -> Vec { - let public_key = KeyPair::get_by_pk(ctx, key_pair_pk) - .await - .expect("failed to fetch key pair"); +) -> Result> { + let public_key = KeyPair::get_by_pk(ctx, key_pair_pk).await?; let crypted = sodiumoxide::crypto::sealedbox::seal( - &serde_json::to_vec(message).expect("failed to serialize message"), + &serde_json::to_vec(message)?, public_key.public_key(), ); - crypted + Ok(crypted) } /// Fetches the value stored at "/root/resource/last_synced" for the provided [`Component`]. pub async fn fetch_resource_last_synced_value( ctx: &DalContext, component_id: ComponentId, -) -> DalTestHelpersResult> { +) -> Result> { let mut attribute_value_ids = Component::attribute_values_for_prop_by_id( ctx, component_id, @@ -284,9 +200,9 @@ pub async fn fetch_resource_last_synced_value( .await?; let attribute_value_id = attribute_value_ids .pop() - .ok_or(DalTestHelpersError::UnexpectedEmptyAttributeValues)?; + .ok_or(eyre!("unexpected: no attribute values found"))?; if !attribute_value_ids.is_empty() { - return Err(DalTestHelpersError::TooManyAttributeValues); + return Err(eyre!("unexpected: more than one attribute value found")); } let last_synced_value = AttributeValue::get_by_id(ctx, attribute_value_id) @@ -295,139 +211,3 @@ pub async fn fetch_resource_last_synced_value( .await?; Ok(last_synced_value) } - -#[allow(missing_docs)] -#[derive(Serialize, Deserialize, Debug)] -pub struct PropEditorTestView { - pub prop: PropertyEditorProp, - pub value: PropertyEditorValue, - #[serde(skip_serializing_if = "Option::is_none")] - pub children: Option>, -} - -impl PropEditorTestView { - fn get_view(&self, prop_path: &[&str]) -> Value { - let mut value = serde_json::to_value(self).expect("convert UnifiedViewItem to json Value"); - - // "root" is necessary for compatibility with other prop apis, but we skip it here - for &prop_name in prop_path.iter().skip(1) { - value = value - .get("children") - .expect("get children entry of PropEditorView") - .get(prop_name) - .expect("get child entry of PropEditorView") - .clone(); - } - - value - } - - /// Gets the "value" for a given [`Prop`](dal::Prop) path. - pub fn get_value(&self, prop_path: &[&str]) -> Value { - let view = self.get_view(prop_path); - view.get("value").expect("get prop field of view").clone() - } - - /// Generates a [`PropEditorTestView`] for a given [`ComponentId`](Component). - pub async fn for_component_id(ctx: &DalContext, component_id: ComponentId) -> Self { - let sv_id = Component::schema_variant_id(ctx, component_id) - .await - .expect("get schema variant from component"); - - let PropertyEditorValues { - root_value_id, - values, - child_values, - } = PropertyEditorValues::assemble(ctx, component_id) - .await - .expect("assemble property editor values"); - - let PropertyEditorSchema { props, .. } = PropertyEditorSchema::assemble(ctx, sv_id) - .await - .expect("assemble property editor schema"); - - let root_view = { - let value = values - .get(&root_value_id) - .expect("get property editor root value") - .clone(); - - let prop = props.get(&value.prop_id).expect("get property editor prop"); - - Self { - prop: prop.clone(), - value, - children: Self::property_editor_compile_children( - ctx, - root_value_id, - &prop.kind, - &values, - &child_values, - &props, - ) - .await, - } - }; - - root_view - } - - #[async_recursion] - async fn property_editor_compile_children( - ctx: &DalContext, - parent_value_id: PropertyEditorValueId, - parent_prop_kind: &PropertyEditorPropKind, - values: &HashMap, - child_values: &HashMap>, - props: &HashMap, - ) -> Option> { - let mut children = HashMap::new(); - - for (index, child_id) in enumerate( - child_values - .get(&parent_value_id) - .expect("get prop editor value children"), - ) { - let value = values - .get(child_id) - .expect("get property editor root value") - .clone(); - let real_prop = Prop::get_by_id_or_error(ctx, value.prop_id.into_inner().into()) - .await - .expect("prop should exist"); - if real_prop.hidden { - continue; - } - - let prop = props.get(&value.prop_id).expect("get property editor prop"); - - let key = match parent_prop_kind { - PropertyEditorPropKind::Array => index.to_string(), - PropertyEditorPropKind::Map => value.key.clone().unwrap_or("ERROR".to_string()), - _ => prop.name.clone(), - }; - - let child = PropEditorTestView { - prop: prop.clone(), - value, - children: Self::property_editor_compile_children( - ctx, - *child_id, - &prop.kind, - values, - child_values, - props, - ) - .await, - }; - - children.insert(key, child); - } - - if children.is_empty() { - None - } else { - Some(children) - } - } -} diff --git a/lib/dal-test/src/helpers/change_set.rs b/lib/dal-test/src/helpers/change_set.rs index 213322111e..1f52cb0814 100644 --- a/lib/dal-test/src/helpers/change_set.rs +++ b/lib/dal-test/src/helpers/change_set.rs @@ -1,52 +1,15 @@ //! This module provides [`ChangeSetTestHelpers`]. -#![warn( - clippy::missing_panics_doc, - clippy::panic, - clippy::panic_in_result_fn, - clippy::unwrap_in_result, - clippy::unwrap_used -)] - use std::time::Duration; +use color_eyre::eyre::eyre; +use color_eyre::Result; use dal::action::dependency_graph::ActionDependencyGraph; use dal::action::{Action, ActionState}; -use dal::context::Conflicts; -use dal::{ - action::ActionError, ChangeSet, ChangeSetApplyError, ChangeSetError, ChangeSetId, DalContext, - TransactionsError, -}; -use thiserror::Error; +use dal::{ChangeSet, DalContext}; use crate::helpers::generate_fake_name; -#[allow(missing_docs)] -#[remain::sorted] -#[derive(Error, Debug)] -pub enum ChangeSetTestHelpersError { - #[error("action error: {0}")] - Action(#[from] ActionError), - #[error("timeout waiting for actions to clear from test workspace")] - ActionTimeout, - #[error("base change set not found for change set: {0}")] - BaseChangeSetNotFound(ChangeSetId), - #[error("change set error: {0}")] - ChangeSet(#[from] ChangeSetError), - #[error("change set apply error: {0}")] - ChangeSetApply(#[from] ChangeSetApplyError), - #[error("change set not found by id: {0}")] - ChangeSetNotFound(ChangeSetId), - #[error("found conflicts after apply: {0:?}")] - ConflictsFoundAfterApply(Conflicts), - #[error("found conflicts after commit: {0:?}")] - ConflictsFoundAfterCommit(Conflicts), - #[error("transactions error: {0}")] - Transactions(#[from] TransactionsError), -} - -type ChangeSetTestHelpersResult = Result; - /// This unit struct providers helper functions for working with [`ChangeSets`](ChangeSet). It is /// designed to centralize logic for test authors wishing to commit changes, fork, apply, abandon, /// etc. @@ -56,9 +19,7 @@ pub struct ChangeSetTestHelpers; impl ChangeSetTestHelpers { /// First, this function performs a blocking commit which will return an error if /// there are conflicts. Then, it updates the snapshot to the current visibility. - pub async fn commit_and_update_snapshot_to_visibility( - ctx: &mut DalContext, - ) -> ChangeSetTestHelpersResult<()> { + pub async fn commit_and_update_snapshot_to_visibility(ctx: &mut DalContext) -> Result<()> { Self::blocking_commit(ctx).await?; ctx.update_snapshot_to_visibility().await?; Ok(()) @@ -67,7 +28,7 @@ impl ChangeSetTestHelpers { /// Wait for all actions queued on the workspace snapshot to either succeed (and therefore not /// be on the graph), fail, or be put on hold. Will wait for at least 10 seconds, checking every /// 100ms. - pub async fn wait_for_actions_to_run(ctx: &mut DalContext) -> ChangeSetTestHelpersResult<()> { + pub async fn wait_for_actions_to_run(ctx: &mut DalContext) -> Result<()> { let total_count = 100; let mut count = 0; @@ -90,37 +51,34 @@ impl ChangeSetTestHelpers { count += 1; tokio::time::sleep(Duration::from_millis(100)).await; } - Err(ChangeSetTestHelpersError::ActionTimeout) + Err(eyre!( + "timeout waiting for actions to clear from test workspace" + )) } /// Applies the current [`ChangeSet`] to its base [`ChangeSet`]. Then, it updates the snapshot /// to the visibility without using an editing [`ChangeSet`]. In other words, the resulting, /// snapshot is "HEAD" without an editing [`ChangeSet`]. - pub async fn apply_change_set_to_base(ctx: &mut DalContext) -> ChangeSetTestHelpersResult<()> { - let applied_change_set = match ChangeSet::apply_to_base_change_set(ctx).await { - Err(ChangeSetApplyError::ConflictsOnApply(conflicts)) => Err( - ChangeSetTestHelpersError::ConflictsFoundAfterApply(conflicts), - )?, - err @ Err(_) => err?, - Ok(change_set) => change_set, - }; + pub async fn apply_change_set_to_base(ctx: &mut DalContext) -> Result<()> { + let applied_change_set = ChangeSet::apply_to_base_change_set(ctx).await?; Self::blocking_commit(ctx).await?; ctx.update_visibility_and_snapshot_to_visibility_no_editing_change_set( - applied_change_set.base_change_set_id.ok_or( - ChangeSetTestHelpersError::BaseChangeSetNotFound(applied_change_set.id), - )?, + applied_change_set.base_change_set_id.ok_or(eyre!( + "base change set not found for change set: {}", + applied_change_set.id + ))?, ) .await?; Ok(()) } /// Abandons the current [`ChangeSet`]. - pub async fn abandon_change_set(ctx: &mut DalContext) -> ChangeSetTestHelpersResult<()> { - let mut abandonment_change_set = ChangeSet::find(ctx, ctx.change_set_id()).await?.ok_or( - ChangeSetTestHelpersError::ChangeSetNotFound(ctx.change_set_id()), - )?; + pub async fn abandon_change_set(ctx: &mut DalContext) -> Result<()> { + let mut abandonment_change_set = ChangeSet::find(ctx, ctx.change_set_id()) + .await? + .ok_or(eyre!("change set not found by id: {}", ctx.change_set_id()))?; abandonment_change_set.abandon(ctx).await?; Ok(()) } @@ -129,10 +87,8 @@ impl ChangeSetTestHelpers { /// The name of the forked [`ChangeSet`] will be random. /// /// If you'd like to provide a name, use [`Self::fork_from_head_change_set_with_name`]. - pub async fn fork_from_head_change_set( - ctx: &mut DalContext, - ) -> ChangeSetTestHelpersResult { - Self::fork_from_head_change_set_inner(ctx, generate_fake_name()).await + pub async fn fork_from_head_change_set(ctx: &mut DalContext) -> Result { + Self::fork_from_head_change_set_inner(ctx, generate_fake_name()?).await } /// "Forks" from the "HEAD" [`ChangeSet`], which is the default [`ChangeSet`] of the workspace. @@ -142,14 +98,14 @@ impl ChangeSetTestHelpers { pub async fn fork_from_head_change_set_with_name( ctx: &mut DalContext, name: impl AsRef, - ) -> ChangeSetTestHelpersResult { + ) -> Result { Self::fork_from_head_change_set_inner(ctx, name).await } async fn fork_from_head_change_set_inner( ctx: &mut DalContext, name: impl AsRef, - ) -> ChangeSetTestHelpersResult { + ) -> Result { let new_change_set = ChangeSet::fork_head(ctx, name).await?; ctx.update_visibility_and_snapshot_to_visibility(new_change_set.id) @@ -158,13 +114,11 @@ impl ChangeSetTestHelpers { Ok(new_change_set) } - async fn blocking_commit(ctx: &DalContext) -> ChangeSetTestHelpersResult<()> { + async fn blocking_commit(ctx: &DalContext) -> Result<()> { // TODO(nick,brit): we need to expand Brit's 409 conflict work to work with blocking commits // too rather than evaluating an optional set of conflicts. match ctx.blocking_commit().await? { - Some(conflicts) => Err(ChangeSetTestHelpersError::ConflictsFoundAfterCommit( - conflicts, - )), + Some(conflicts) => Err(eyre!("found conflicts after commit: {conflicts:?}")), None => Ok(()), } } diff --git a/lib/dal-test/src/helpers/property_editor_test_view.rs b/lib/dal-test/src/helpers/property_editor_test_view.rs new file mode 100644 index 0000000000..0fdf7fb3ee --- /dev/null +++ b/lib/dal-test/src/helpers/property_editor_test_view.rs @@ -0,0 +1,149 @@ +use async_recursion::async_recursion; +use color_eyre::eyre::eyre; +use color_eyre::Result; +use dal::property_editor::schema::{ + PropertyEditorProp, PropertyEditorPropKind, PropertyEditorSchema, +}; +use dal::property_editor::values::{PropertyEditorValue, PropertyEditorValues}; +use dal::property_editor::{PropertyEditorPropId, PropertyEditorValueId}; +use dal::{Component, ComponentId, DalContext, Prop}; +use itertools::enumerate; +use serde::{Deserialize, Serialize}; +use serde_json::Value; +use std::collections::HashMap; + +#[allow(missing_docs)] +#[derive(Serialize, Deserialize, Debug)] +pub struct PropEditorTestView { + pub prop: PropertyEditorProp, + pub value: PropertyEditorValue, + #[serde(skip_serializing_if = "Option::is_none")] + pub children: Option>, +} + +impl PropEditorTestView { + fn get_view(&self, prop_path: &[&str]) -> crate::Result { + let mut value = serde_json::to_value(self)?; + + // "root" is necessary for compatibility with other prop apis, but we skip it here + for &prop_name in prop_path.iter().skip(1) { + value = value + .get("children") + .ok_or(eyre!("nothing found in children entry for view"))? + .get(prop_name) + .ok_or(eyre!("specific child entry not found for view"))? + .clone(); + } + + Ok(value) + } + + /// Gets the "value" for a given [`Prop`](dal::Prop) path. + pub fn get_value(&self, prop_path: &[&str]) -> crate::Result { + let view = self.get_view(prop_path)?; + Ok(view.get("value").ok_or(eyre!("value not found"))?.clone()) + } + + /// Generates a [`PropEditorTestView`] for a given [`ComponentId`](Component). + pub async fn for_component_id( + ctx: &DalContext, + component_id: ComponentId, + ) -> crate::Result { + let sv_id = Component::schema_variant_id(ctx, component_id).await?; + + let PropertyEditorValues { + root_value_id, + values, + child_values, + } = PropertyEditorValues::assemble(ctx, component_id).await?; + + let PropertyEditorSchema { props, .. } = PropertyEditorSchema::assemble(ctx, sv_id).await?; + + let root_view = { + let value = values + .get(&root_value_id) + .ok_or(eyre!("no value for root value"))? + .clone(); + + let prop = props + .get(&value.prop_id) + .ok_or(eyre!("property editor prop not found"))?; + + Self { + prop: prop.clone(), + value, + children: Self::property_editor_compile_children( + ctx, + root_value_id, + &prop.kind, + &values, + &child_values, + &props, + ) + .await?, + } + }; + + Ok(root_view) + } + + #[async_recursion] + async fn property_editor_compile_children( + ctx: &DalContext, + parent_value_id: PropertyEditorValueId, + parent_prop_kind: &PropertyEditorPropKind, + values: &HashMap, + child_values: &HashMap>, + props: &HashMap, + ) -> Result>> { + let mut children = HashMap::new(); + + for (index, child_id) in enumerate( + child_values + .get(&parent_value_id) + .ok_or(eyre!("could not get children for parent"))?, + ) { + let value = values + .get(child_id) + .ok_or(eyre!("could not get value for child"))? + .clone(); + let real_prop = + Prop::get_by_id_or_error(ctx, value.prop_id.into_inner().into()).await?; + if real_prop.hidden { + continue; + } + + let prop = props + .get(&value.prop_id) + .ok_or(eyre!("could not get property editor prop"))?; + + let key = match parent_prop_kind { + PropertyEditorPropKind::Array => index.to_string(), + PropertyEditorPropKind::Map => value.key.clone().unwrap_or("ERROR".to_string()), + _ => prop.name.clone(), + }; + + let child = PropEditorTestView { + prop: prop.clone(), + value, + children: Self::property_editor_compile_children( + ctx, + *child_id, + &prop.kind, + values, + child_values, + props, + ) + .await?, + }; + + children.insert(key, child); + } + + Ok(if children.is_empty() { + None + } else { + Some(children) + }) + } +} diff --git a/lib/dal-test/src/lib.rs b/lib/dal-test/src/lib.rs index 5c339f5c42..b200b3e706 100644 --- a/lib/dal-test/src/lib.rs +++ b/lib/dal-test/src/lib.rs @@ -3,6 +3,9 @@ #![warn( bad_style, + clippy::expect_used, + clippy::panic, + clippy::unwrap_used, dead_code, improper_ctypes, missing_debug_implementations, @@ -31,7 +34,7 @@ use std::{ use buck2_resources::Buck2Resources; use dal::{ - builtins::{func, schema}, + builtins::func, feature_flags::FeatureFlagService, job::processor::{JobQueueProcessor, NatsProcessor}, DalContext, DalLayerDb, JwtPublicSigningKey, ModelResult, ServicesContext, Workspace, @@ -52,10 +55,15 @@ use tokio::{fs::File, io::AsyncReadExt, sync::Mutex}; use tokio_util::{sync::CancellationToken, task::TaskTracker}; use uuid::Uuid; +/// This module contains helpers for macro expansion. We allow panics and "expects" here because we +/// want to bail during macro expansion. We still do not allow "unwrap" because "expect" should be +/// used instead. +#[allow(clippy::expect_used, clippy::panic)] pub mod expand_helpers; + pub mod helpers; -mod schemas; mod signup; +mod test_exclusive_schemas; pub use color_eyre::{ self, @@ -77,9 +85,6 @@ const ENV_VAR_LAYER_CACHE_PG_DBNAME: &str = "SI_TEST_LAYER_CACHE_PG_DBNAME"; const ENV_VAR_PG_USER: &str = "SI_TEST_PG_USER"; const ENV_VAR_PG_PORT: &str = "SI_TEST_PG_PORT"; const ENV_VAR_KEEP_OLD_DBS: &str = "SI_TEST_KEEP_OLD_DBS"; -const SI_AWS_EC2_PKG: &str = "si-aws-ec2-2023-09-26.sipkg"; -const SI_DOCKER_IMAGE_PKG: &str = "si-docker-image-2023-09-13.sipkg"; -const SI_COREOS_PKG: &str = "si-coreos-2023-09-13.sipkg"; #[allow(missing_docs)] pub static COLOR_EYRE_INIT: Once = Once::new(); @@ -348,6 +353,7 @@ impl TestContext { } /// Creates a new [`ServicesContext`]. + #[allow(clippy::expect_used, clippy::panic)] pub async fn create_services_context( &self, token: CancellationToken, @@ -541,6 +547,7 @@ pub async fn jwt_public_signing_key() -> Result { } /// Returns a JWT private signing key, which is used to sign claims. +#[allow(clippy::expect_used, clippy::panic)] pub async fn jwt_private_signing_key() -> Result { let key_path = { let context_builder = TEST_CONTEXT_BUILDER.lock().await; @@ -734,9 +741,12 @@ async fn global_setup(test_context_builer: TestContextBuilder) -> Result<()> { tracker.close(); - // Check if the user would like to skip migrating schemas. This is helpful for boosting - // performance when running integration tests that do not rely on builtin schemas. - // let selected_test_builtin_schemas = determine_selected_test_builtin_schemas(); + #[allow(clippy::expect_used)] + let pkgs_path = test_context + .config + .pkgs_path + .to_owned() + .expect("no pkgs path configured"); info!("creating builtins"); migrate_local_builtins( @@ -745,11 +755,7 @@ async fn global_setup(test_context_builer: TestContextBuilder) -> Result<()> { services_ctx.job_processor(), services_ctx.veritech().clone(), &services_ctx.encryption_key(), - test_context - .config - .pkgs_path - .to_owned() - .expect("no pkgs path configured"), + pkgs_path, test_context.config.module_index_url.clone(), services_ctx.symmetric_crypto_service(), services_ctx.layer_db().clone(), @@ -813,72 +819,15 @@ async fn migrate_local_builtins( info!("migrating intrinsic functions"); func::migrate_intrinsics(&ctx).await?; - // FIXME(nick): restore builtin migration functionality for all variants. - info!("migrate minimal number of schemas for testing the new engine"); - - schema::migrate_pkg(&ctx, SI_DOCKER_IMAGE_PKG, None).await?; - schema::migrate_pkg(&ctx, SI_COREOS_PKG, None).await?; - schema::migrate_pkg(&ctx, SI_AWS_EC2_PKG, None).await?; - schemas::migrate_test_exclusive_schema_starfield(&ctx).await?; - schemas::migrate_test_exclusive_schema_etoiles(&ctx).await?; - schemas::migrate_test_exclusive_schema_morningstar(&ctx).await?; - schemas::migrate_test_exclusive_schema_fallout(&ctx).await?; - schemas::migrate_test_exclusive_schema_dummy_secret(&ctx).await?; - schemas::migrate_test_exclusive_schema_swifty(&ctx).await?; - schemas::migrate_test_exclusive_schema_katy_perry(&ctx).await?; - schemas::migrate_test_exclusive_schema_pirate(&ctx).await?; - schemas::migrate_test_exclusive_schema_pet_shop(&ctx).await?; - schemas::migrate_test_exclusive_schema_validated_input(&ctx).await?; - schemas::migrate_test_exclusive_schema_validated_output(&ctx).await?; - schemas::migrate_test_exclusive_schema_bad_validations(&ctx).await?; - schemas::migrate_test_exclusive_schema_large_odd_lego(&ctx).await?; - schemas::migrate_test_exclusive_schema_large_even_lego(&ctx).await?; - schemas::migrate_test_exclusive_schema_medium_even_lego(&ctx).await?; - schemas::migrate_test_exclusive_schema_medium_odd_lego(&ctx).await?; - schemas::migrate_test_exclusive_schema_small_odd_lego(&ctx).await?; - schemas::migrate_test_exclusive_schema_small_even_lego(&ctx).await?; + info!("migrating test exclusive schemas"); + test_exclusive_schemas::migrate(&ctx).await?; + + info!("migrations complete, commiting"); ctx.blocking_commit().await?; Ok(()) } -// fn determine_selected_test_builtin_schemas() -> SelectedTestBuiltinSchemas { -// #[allow(clippy::disallowed_methods)] // Environment variables are used exclusively in test and -// // all are prefixed with `SI_TEST_` -// // -// // TODO(fnichol): remove conditional schema execution -// match env::var(ENV_VAR_BUILTIN_SCHEMAS) { -// Ok(found_value) => { -// let mut builtin_schemas = HashSet::new(); -// -// // If the value does not contain a comma, we will have exactly once item to iterate -// // over. -// for builtin_schema in found_value.split(',') { -// // Trim and ensure the string is lowercase. -// let cleaned = builtin_schema.trim().to_lowercase(); -// -// // If we receive any keywords indicating that we need to return early, let's do so. -// if &cleaned == "none" || &cleaned == "false" { -// return SelectedTestBuiltinSchemas::None; -// } else if &cleaned == "all" { -// return SelectedTestBuiltinSchemas::All; -// } else if &cleaned == "test" || &cleaned == "true" { -// return SelectedTestBuiltinSchemas::Test; -// } -// -// // If we do not find any keywords, we assume that the user provided the name for a -// // builtin schema. -// builtin_schemas.insert(cleaned); -// } -// SelectedTestBuiltinSchemas::Some(builtin_schemas) -// } -// Err(_) => { -// // If the variable is unset, then we migrate everything. This is the default behavior. -// SelectedTestBuiltinSchemas::Test -// } -// } -// } - async fn drop_old_test_databases(pg_pool: &PgPool) -> Result<()> { let name_prefix = format!("{}_%", pg_pool.db_name()); let pg_conn = pg_pool.get().await?; diff --git a/lib/dal-test/src/schemas/mod.rs b/lib/dal-test/src/schemas/mod.rs deleted file mode 100644 index c009e5a475..0000000000 --- a/lib/dal-test/src/schemas/mod.rs +++ /dev/null @@ -1,31 +0,0 @@ -pub(crate) use test_exclusive_lego_schemas::migrate_test_exclusive_schema_large_even_lego; -pub(crate) use test_exclusive_lego_schemas::migrate_test_exclusive_schema_large_odd_lego; -pub(crate) use test_exclusive_lego_schemas::migrate_test_exclusive_schema_medium_even_lego; -pub(crate) use test_exclusive_lego_schemas::migrate_test_exclusive_schema_medium_odd_lego; -pub(crate) use test_exclusive_lego_schemas::migrate_test_exclusive_schema_small_even_lego; -pub(crate) use test_exclusive_lego_schemas::migrate_test_exclusive_schema_small_odd_lego; -pub(crate) use test_exclusive_schema_category_pirate::migrate_test_exclusive_schema_pet_shop; -pub(crate) use test_exclusive_schema_category_pirate::migrate_test_exclusive_schema_pirate; -pub(crate) use test_exclusive_schema_category_validated::migrate_test_exclusive_schema_bad_validations; -pub(crate) use test_exclusive_schema_category_validated::migrate_test_exclusive_schema_validated_input; -pub(crate) use test_exclusive_schema_category_validated::migrate_test_exclusive_schema_validated_output; -pub(crate) use test_exclusive_schema_dummy_secret::migrate_test_exclusive_schema_dummy_secret; -pub(crate) use test_exclusive_schema_fallout::migrate_test_exclusive_schema_fallout; -pub(crate) use test_exclusive_schema_katy_perry::migrate_test_exclusive_schema_katy_perry; -pub(crate) use test_exclusive_schema_starfield::migrate_test_exclusive_schema_etoiles; -pub(crate) use test_exclusive_schema_starfield::migrate_test_exclusive_schema_morningstar; -pub(crate) use test_exclusive_schema_starfield::migrate_test_exclusive_schema_starfield; -pub(crate) use test_exclusive_schema_swifty::migrate_test_exclusive_schema_swifty; - -const PKG_VERSION: &str = "2019-06-03"; -const PKG_CREATED_BY: &str = "System Initiative"; - -mod schema_helpers; -mod test_exclusive_lego_schemas; -mod test_exclusive_schema_category_pirate; -mod test_exclusive_schema_category_validated; -mod test_exclusive_schema_dummy_secret; -mod test_exclusive_schema_fallout; -mod test_exclusive_schema_katy_perry; -mod test_exclusive_schema_starfield; -mod test_exclusive_schema_swifty; diff --git a/lib/dal-test/src/schemas/schema_helpers.rs b/lib/dal-test/src/schemas/schema_helpers.rs deleted file mode 100644 index 48e7cd830c..0000000000 --- a/lib/dal-test/src/schemas/schema_helpers.rs +++ /dev/null @@ -1,101 +0,0 @@ -use dal::func::argument::FuncArgumentKind; -use dal::func::intrinsics::IntrinsicFunc; -use dal::{BuiltinsError, BuiltinsResult}; -use si_pkg::{ - FuncArgumentSpec, FuncSpec, FuncSpecBackendKind, FuncSpecBackendResponseType, FuncSpecData, -}; - -pub(crate) fn create_identity_func() -> BuiltinsResult { - Ok(IntrinsicFunc::Identity.to_spec()?) -} - -pub(crate) async fn build_resource_payload_to_value_func() -> BuiltinsResult { - let resource_payload_to_value_func_code = "async function main(arg: Input): Promise {\ - return arg.payload ?? {}; - }"; - let fn_name = "test:resourcePayloadToValue"; - let resource_payload_to_value_func = FuncSpec::builder() - .name(fn_name) - .unique_id(fn_name) - .data( - FuncSpecData::builder() - .name(fn_name) - .code_plaintext(resource_payload_to_value_func_code) - .handler("main") - .backend_kind(FuncSpecBackendKind::JsAttribute) - .response_type(FuncSpecBackendResponseType::Json) - .build()?, - ) - .argument( - FuncArgumentSpec::builder() - .name("payload") - .kind(FuncArgumentKind::Object) - .build()?, - ) - .build()?; - - Ok(resource_payload_to_value_func) -} - -pub(crate) fn build_action_func(code: &str, fn_name: &str) -> Result { - let func = FuncSpec::builder() - .name(fn_name) - .unique_id(fn_name) - .data( - FuncSpecData::builder() - .name(fn_name) - .code_plaintext(code) - .handler("main") - .backend_kind(FuncSpecBackendKind::JsAction) - .response_type(FuncSpecBackendResponseType::Action) - .build()?, - ) - .build()?; - - Ok(func) -} - -pub(crate) async fn build_codegen_func(code: &str, fn_name: &str) -> BuiltinsResult { - let func = FuncSpec::builder() - .name(fn_name) - .unique_id(fn_name) - .argument( - FuncArgumentSpec::builder() - .name("domain") - .kind(FuncArgumentKind::Object) - .build()?, - ) - .data( - FuncSpecData::builder() - .name(fn_name) - .code_plaintext(code) - .handler("main") - .backend_kind(FuncSpecBackendKind::JsAttribute) - .response_type(FuncSpecBackendResponseType::CodeGeneration) - .build()?, - ) - .build()?; - - Ok(func) -} - -pub(crate) async fn build_asset_func(fn_name: &str) -> BuiltinsResult { - let scaffold_func = "function main() {\ - return new AssetBuilder().build(); - }"; - let asset_func = FuncSpec::builder() - .name(fn_name) - .unique_id(fn_name) - .data( - FuncSpecData::builder() - .name(fn_name) - .code_plaintext(scaffold_func) - .handler("main") - .backend_kind(FuncSpecBackendKind::JsSchemaVariantDefinition) - .response_type(FuncSpecBackendResponseType::SchemaVariantDefinition) - .build()?, - ) - .build()?; - - Ok(asset_func) -} diff --git a/lib/dal-test/src/schemas/test_exclusive_lego_schemas/mod.rs b/lib/dal-test/src/schemas/test_exclusive_lego_schemas/mod.rs deleted file mode 100644 index b31055da23..0000000000 --- a/lib/dal-test/src/schemas/test_exclusive_lego_schemas/mod.rs +++ /dev/null @@ -1,11 +0,0 @@ -pub(crate) use test_exclusive_schema_lego_large::migrate_test_exclusive_schema_large_even_lego; -pub(crate) use test_exclusive_schema_lego_large::migrate_test_exclusive_schema_large_odd_lego; -pub(crate) use test_exclusive_schema_lego_medium::migrate_test_exclusive_schema_medium_even_lego; -pub(crate) use test_exclusive_schema_lego_medium::migrate_test_exclusive_schema_medium_odd_lego; -pub(crate) use test_exclusive_schema_lego_small::migrate_test_exclusive_schema_small_even_lego; -pub(crate) use test_exclusive_schema_lego_small::migrate_test_exclusive_schema_small_odd_lego; - -mod bricks; -mod test_exclusive_schema_lego_large; -mod test_exclusive_schema_lego_medium; -mod test_exclusive_schema_lego_small; diff --git a/lib/dal-test/src/schemas/test_exclusive_schema_category_pirate.rs b/lib/dal-test/src/test_exclusive_schemas/category_pirate.rs similarity index 90% rename from lib/dal-test/src/schemas/test_exclusive_schema_category_pirate.rs rename to lib/dal-test/src/test_exclusive_schemas/category_pirate.rs index d227ef7bae..f42ad1d567 100644 --- a/lib/dal-test/src/schemas/test_exclusive_schema_category_pirate.rs +++ b/lib/dal-test/src/test_exclusive_schemas/category_pirate.rs @@ -1,4 +1,3 @@ -use crate::schemas::schema_helpers::{build_asset_func, create_identity_func}; use dal::pkg::import_pkg_from_pkg; use dal::{prop::PropPath, ComponentType}; use dal::{BuiltinsResult, DalContext, PropKind}; @@ -8,6 +7,10 @@ use si_pkg::{ }; use si_pkg::{SchemaSpecData, SocketSpec, SocketSpecData, SocketSpecKind}; +use crate::test_exclusive_schemas::{ + build_asset_func, create_identity_func, PKG_CREATED_BY, PKG_VERSION, +}; + const CATEGORY: &str = "pirate"; pub(crate) async fn migrate_test_exclusive_schema_pirate(ctx: &DalContext) -> BuiltinsResult<()> { @@ -17,14 +20,14 @@ pub(crate) async fn migrate_test_exclusive_schema_pirate(ctx: &DalContext) -> Bu builder .name(schema_name) - .version(crate::schemas::PKG_VERSION) - .created_by(crate::schemas::PKG_CREATED_BY); + .version(PKG_VERSION) + .created_by(PKG_CREATED_BY); let identity_func_spec = create_identity_func()?; // Create Scaffold Func let fn_name = "test:scaffoldPirateAsset"; - let authoring_schema_func = build_asset_func(fn_name).await?; + let authoring_schema_func = build_asset_func(fn_name)?; let schema = SchemaSpec::builder() .name(schema_name) @@ -33,8 +36,7 @@ pub(crate) async fn migrate_test_exclusive_schema_pirate(ctx: &DalContext) -> Bu .name(schema_name) .category("test exclusive") .category_name(CATEGORY) - .build() - .expect("schema spec data build"), + .build()?, ) .variant( SchemaVariantSpec::builder() @@ -45,8 +47,7 @@ pub(crate) async fn migrate_test_exclusive_schema_pirate(ctx: &DalContext) -> Bu .color("#ff00ff") .func_unique_id(&authoring_schema_func.unique_id) .component_type(ComponentType::Component) - .build() - .expect("build variant spec data"), + .build()?, ) .domain_prop( PropSpec::builder() @@ -138,14 +139,14 @@ pub(crate) async fn migrate_test_exclusive_schema_pet_shop(ctx: &DalContext) -> builder .name(schema_name) - .version(crate::schemas::PKG_VERSION) - .created_by(crate::schemas::PKG_CREATED_BY); + .version(PKG_VERSION) + .created_by(PKG_CREATED_BY); let identity_func_spec = create_identity_func()?; // Create Scaffold Func let fn_name = "test:scaffoldPetShopAsset"; - let authoring_schema_func = build_asset_func(fn_name).await?; + let authoring_schema_func = build_asset_func(fn_name)?; let schema = SchemaSpec::builder() .name(schema_name) @@ -154,8 +155,7 @@ pub(crate) async fn migrate_test_exclusive_schema_pet_shop(ctx: &DalContext) -> .name(schema_name) .category("test exclusive") .category_name(CATEGORY) - .build() - .expect("schema spec data build"), + .build()?, ) .variant( SchemaVariantSpec::builder() @@ -166,8 +166,7 @@ pub(crate) async fn migrate_test_exclusive_schema_pet_shop(ctx: &DalContext) -> .color("#ff00ff") .func_unique_id(&authoring_schema_func.unique_id) .component_type(ComponentType::Component) - .build() - .expect("build variant spec data"), + .build()?, ) .domain_prop( PropSpec::builder() diff --git a/lib/dal-test/src/schemas/test_exclusive_schema_category_validated.rs b/lib/dal-test/src/test_exclusive_schemas/category_validated.rs similarity index 93% rename from lib/dal-test/src/schemas/test_exclusive_schema_category_validated.rs rename to lib/dal-test/src/test_exclusive_schemas/category_validated.rs index 4acf913f56..f7814455bd 100644 --- a/lib/dal-test/src/schemas/test_exclusive_schema_category_validated.rs +++ b/lib/dal-test/src/test_exclusive_schemas/category_validated.rs @@ -1,4 +1,3 @@ -use crate::schemas::schema_helpers::{build_asset_func, create_identity_func}; use dal::pkg::import_pkg_from_pkg; use dal::{prop::PropPath, ComponentType}; use dal::{BuiltinsResult, DalContext, PropKind}; @@ -8,6 +7,8 @@ use si_pkg::{ }; use si_pkg::{SchemaSpecData, SocketSpec, SocketSpecData, SocketSpecKind}; +use crate::test_exclusive_schemas::{build_asset_func, create_identity_func}; + const CATEGORY: &str = "validations"; pub(crate) async fn migrate_test_exclusive_schema_bad_validations( @@ -26,7 +27,7 @@ pub(crate) async fn migrate_test_exclusive_schema_bad_validations( // Create Scaffold Func let fn_name = format!("test:scaffold{schema_name}Asset"); - let authoring_schema_func = build_asset_func(fn_name.as_str()).await?; + let authoring_schema_func = build_asset_func(fn_name.as_str())?; let schema = SchemaSpec::builder() .name(schema_name) @@ -35,8 +36,7 @@ pub(crate) async fn migrate_test_exclusive_schema_bad_validations( .name(schema_name) .category("test exclusive") .category_name(CATEGORY) - .build() - .expect("schema spec data build"), + .build()? ) .variant( SchemaVariantSpec::builder() @@ -47,8 +47,7 @@ pub(crate) async fn migrate_test_exclusive_schema_bad_validations( .color("#ff00ff") .func_unique_id(&authoring_schema_func.unique_id) .component_type(ComponentType::Component) - .build() - .expect("build variant spec data"), + .build()? ) .domain_prop( PropSpec::builder() @@ -103,7 +102,7 @@ pub(crate) async fn migrate_test_exclusive_schema_validated_output( // Create Scaffold Func let fn_name = format!("test:scaffold{schema_name}Asset"); - let authoring_schema_func = build_asset_func(fn_name.as_str()).await?; + let authoring_schema_func = build_asset_func(fn_name.as_str())?; let schema = SchemaSpec::builder() .name(schema_name) @@ -112,9 +111,7 @@ pub(crate) async fn migrate_test_exclusive_schema_validated_output( .name(schema_name) .category("test exclusive") .category_name(CATEGORY) - .build() - .expect("schema spec data build"), - ) + .build()?) .variant( SchemaVariantSpec::builder() .name("v0") @@ -124,8 +121,7 @@ pub(crate) async fn migrate_test_exclusive_schema_validated_output( .color("#ff00ff") .func_unique_id(&authoring_schema_func.unique_id) .component_type(ComponentType::Component) - .build() - .expect("build variant spec data"), + .build()? ) .domain_prop( PropSpec::builder() @@ -188,7 +184,7 @@ pub(crate) async fn migrate_test_exclusive_schema_validated_input( // Create Scaffold Func let fn_name = format!("test:scaffold{schema_name}Asset"); - let authoring_schema_func = build_asset_func(fn_name.as_str()).await?; + let authoring_schema_func = build_asset_func(fn_name.as_str())?; let schema = SchemaSpec::builder() .name(schema_name) @@ -197,8 +193,7 @@ pub(crate) async fn migrate_test_exclusive_schema_validated_input( .name(schema_name) .category("test exclusive") .category_name(CATEGORY) - .build() - .expect("schema spec data build"), + .build()? ) .variant( SchemaVariantSpec::builder() @@ -209,8 +204,7 @@ pub(crate) async fn migrate_test_exclusive_schema_validated_input( .color("#ff00ff") .func_unique_id(&authoring_schema_func.unique_id) .component_type(ComponentType::Component) - .build() - .expect("build variant spec data"), + .build()? ) .domain_prop( PropSpec::builder() diff --git a/lib/dal-test/src/schemas/test_exclusive_schema_dummy_secret.rs b/lib/dal-test/src/test_exclusive_schemas/dummy_secret.rs similarity index 97% rename from lib/dal-test/src/schemas/test_exclusive_schema_dummy_secret.rs rename to lib/dal-test/src/test_exclusive_schemas/dummy_secret.rs index 7850978dc0..a28e44c71d 100644 --- a/lib/dal-test/src/schemas/test_exclusive_schema_dummy_secret.rs +++ b/lib/dal-test/src/test_exclusive_schemas/dummy_secret.rs @@ -14,6 +14,8 @@ use si_pkg::{ SchemaSpecData, SocketSpecArity, }; +use crate::test_exclusive_schemas::{PKG_CREATED_BY, PKG_VERSION}; + pub(crate) async fn migrate_test_exclusive_schema_dummy_secret( ctx: &DalContext, ) -> BuiltinsResult<()> { @@ -32,8 +34,8 @@ fn build_dummy_secret_spec() -> BuiltinsResult { builder .name(name) - .version(crate::schemas::PKG_VERSION) - .created_by(crate::schemas::PKG_CREATED_BY); + .version(PKG_VERSION) + .created_by(PKG_CREATED_BY); let identity_func_spec = IntrinsicFunc::Identity.to_spec()?; @@ -92,8 +94,7 @@ fn build_dummy_secret_spec() -> BuiltinsResult { .name(name) .category("test exclusive") .category_name(name) - .build() - .expect("build schema spec data"), + .build()?, ) .variant( SchemaVariantSpec::builder() diff --git a/lib/dal-test/src/schemas/test_exclusive_schema_fallout.rs b/lib/dal-test/src/test_exclusive_schemas/fallout.rs similarity index 96% rename from lib/dal-test/src/schemas/test_exclusive_schema_fallout.rs rename to lib/dal-test/src/test_exclusive_schemas/fallout.rs index ff9364d500..4e0fcc2a94 100644 --- a/lib/dal-test/src/schemas/test_exclusive_schema_fallout.rs +++ b/lib/dal-test/src/test_exclusive_schemas/fallout.rs @@ -10,9 +10,10 @@ use si_pkg::{ }; use si_pkg::{SchemaSpecData, SocketSpecArity}; -use crate::schemas::schema_helpers::{ +use crate::test_exclusive_schemas::{ build_action_func, build_resource_payload_to_value_func, create_identity_func, }; +use crate::test_exclusive_schemas::{PKG_CREATED_BY, PKG_VERSION}; pub(crate) async fn migrate_test_exclusive_schema_fallout(ctx: &DalContext) -> BuiltinsResult<()> { let mut fallout_builder = PkgSpec::builder(); @@ -21,8 +22,8 @@ pub(crate) async fn migrate_test_exclusive_schema_fallout(ctx: &DalContext) -> B fallout_builder .name(schema_name) - .version(crate::schemas::PKG_VERSION) - .created_by(crate::schemas::PKG_CREATED_BY); + .version(PKG_VERSION) + .created_by(PKG_CREATED_BY); let identity_func_spec = create_identity_func()?; @@ -46,7 +47,7 @@ pub(crate) async fn migrate_test_exclusive_schema_fallout(ctx: &DalContext) -> B ) .build()?; - let resource_payload_to_value_func = build_resource_payload_to_value_func().await?; + let resource_payload_to_value_func = build_resource_payload_to_value_func()?; let (dummy_secret_input_scoket, dummy_secret_prop) = assemble_dummy_secret_socket_and_prop(&identity_func_spec)?; @@ -58,8 +59,7 @@ pub(crate) async fn migrate_test_exclusive_schema_fallout(ctx: &DalContext) -> B .name(schema_name) .category("test exclusive") .category_name(schema_name) - .build() - .expect("build schema spec data"), + .build()?, ) .variant( SchemaVariantSpec::builder() @@ -70,8 +70,7 @@ pub(crate) async fn migrate_test_exclusive_schema_fallout(ctx: &DalContext) -> B .name("v0") .color("#ffffff") .func_unique_id(&fallout_authoring_schema_func.unique_id) - .build() - .expect("fallout variant data"), + .build()?, ) .domain_prop( PropSpec::builder() diff --git a/lib/dal-test/src/schemas/test_exclusive_schema_katy_perry.rs b/lib/dal-test/src/test_exclusive_schemas/katy_perry.rs similarity index 88% rename from lib/dal-test/src/schemas/test_exclusive_schema_katy_perry.rs rename to lib/dal-test/src/test_exclusive_schemas/katy_perry.rs index 9fd03964b5..26d9ad5bbf 100644 --- a/lib/dal-test/src/schemas/test_exclusive_schema_katy_perry.rs +++ b/lib/dal-test/src/test_exclusive_schemas/katy_perry.rs @@ -1,7 +1,3 @@ -use crate::schemas::schema_helpers::{ - build_asset_func, build_codegen_func, build_resource_payload_to_value_func, - create_identity_func, -}; use dal::pkg::import_pkg_from_pkg; use dal::{prop::PropPath, ComponentType}; use dal::{BuiltinsResult, DalContext, PropKind}; @@ -11,6 +7,11 @@ use si_pkg::{ }; use si_pkg::{LeafFunctionSpec, SchemaSpecData}; +use crate::test_exclusive_schemas::{ + build_asset_func, build_codegen_func, build_resource_payload_to_value_func, + create_identity_func, PKG_CREATED_BY, PKG_VERSION, +}; + pub(crate) async fn migrate_test_exclusive_schema_katy_perry( ctx: &DalContext, ) -> BuiltinsResult<()> { @@ -20,17 +21,17 @@ pub(crate) async fn migrate_test_exclusive_schema_katy_perry( kp_builder .name(schema_name) - .version(crate::schemas::PKG_VERSION) - .created_by(crate::schemas::PKG_CREATED_BY); + .version(PKG_VERSION) + .created_by(PKG_CREATED_BY); let identity_func_spec = create_identity_func()?; // Create Scaffold Func let fn_name = "test:scaffoldKatyPerryAsset"; - let kp_authoring_schema_func = build_asset_func(fn_name).await?; + let kp_authoring_schema_func = build_asset_func(fn_name)?; // Author Resource Payload Func - let resource_payload_to_value_func = build_resource_payload_to_value_func().await?; + let resource_payload_to_value_func = build_resource_payload_to_value_func()?; // Build YAML CodeGen Func let yaml_codegen_fn_name = "test:generateYamlCode"; @@ -40,8 +41,7 @@ pub(crate) async fn migrate_test_exclusive_schema_katy_perry( code: Object.keys(input.domain).length > 0 ? YAML.stringify(input.domain) : \"\" }; }"; - let yaml_code_gen_func = - build_codegen_func(yaml_codegen_func_code, yaml_codegen_fn_name).await?; + let yaml_code_gen_func = build_codegen_func(yaml_codegen_func_code, yaml_codegen_fn_name)?; // Build string CodeGen Func let string_codegen_fn_name = "test:generateStringCode"; @@ -52,7 +52,7 @@ pub(crate) async fn migrate_test_exclusive_schema_katy_perry( }; }"; let string_code_gen_func = - build_codegen_func(string_codegen_func_code, string_codegen_fn_name).await?; + build_codegen_func(string_codegen_func_code, string_codegen_fn_name)?; let kp_schema = SchemaSpec::builder() .name(schema_name) @@ -61,8 +61,7 @@ pub(crate) async fn migrate_test_exclusive_schema_katy_perry( .name(schema_name) .category("test exclusive") .category_name(schema_name) - .build() - .expect("schema spec data build"), + .build()?, ) .variant( SchemaVariantSpec::builder() @@ -74,8 +73,7 @@ pub(crate) async fn migrate_test_exclusive_schema_katy_perry( .color("#ffffff") .func_unique_id(&kp_authoring_schema_func.unique_id) .component_type(ComponentType::Component) - .build() - .expect("build variant spec data"), + .build()?, ) .domain_prop( PropSpec::builder() diff --git a/lib/dal-test/src/schemas/test_exclusive_lego_schemas/bricks.rs b/lib/dal-test/src/test_exclusive_schemas/legos/bricks.rs similarity index 99% rename from lib/dal-test/src/schemas/test_exclusive_lego_schemas/bricks.rs rename to lib/dal-test/src/test_exclusive_schemas/legos/bricks.rs index aba7eea824..97861b9dfe 100644 --- a/lib/dal-test/src/schemas/test_exclusive_lego_schemas/bricks.rs +++ b/lib/dal-test/src/test_exclusive_schemas/legos/bricks.rs @@ -5,7 +5,7 @@ use si_pkg::{ SocketSpecKind, }; -use crate::schemas::schema_helpers::create_identity_func; +use crate::test_exclusive_schemas::create_identity_func; #[derive(Debug)] pub(crate) struct LegoBricks { diff --git a/lib/dal-test/src/schemas/test_exclusive_lego_schemas/test_exclusive_schema_lego_large.rs b/lib/dal-test/src/test_exclusive_schemas/legos/large.rs similarity index 92% rename from lib/dal-test/src/schemas/test_exclusive_lego_schemas/test_exclusive_schema_lego_large.rs rename to lib/dal-test/src/test_exclusive_schemas/legos/large.rs index 6055c18ffd..b139ce30bc 100644 --- a/lib/dal-test/src/schemas/test_exclusive_lego_schemas/test_exclusive_schema_lego_large.rs +++ b/lib/dal-test/src/test_exclusive_schemas/legos/large.rs @@ -7,10 +7,11 @@ use si_pkg::{ SiPkg, }; -use crate::schemas::schema_helpers::{ - build_action_func, build_asset_func, build_resource_payload_to_value_func, create_identity_func, +use crate::test_exclusive_schemas::legos::bricks::LegoBricks; +use crate::test_exclusive_schemas::{ + build_action_func, build_asset_func, build_resource_payload_to_value_func, + create_identity_func, PKG_CREATED_BY, PKG_VERSION, }; -use crate::schemas::test_exclusive_lego_schemas::bricks::LegoBricks; pub(crate) async fn migrate_test_exclusive_schema_large_odd_lego( ctx: &DalContext, @@ -21,8 +22,8 @@ pub(crate) async fn migrate_test_exclusive_schema_large_odd_lego( large_lego_builder .name(schema_name) - .version(crate::schemas::PKG_VERSION) - .created_by(crate::schemas::PKG_CREATED_BY); + .version(PKG_VERSION) + .created_by(PKG_CREATED_BY); let identity_func_spec = create_identity_func()?; @@ -50,10 +51,10 @@ pub(crate) async fn migrate_test_exclusive_schema_large_odd_lego( // Create Scaffold Func let fn_name = "test:scaffoldLargeLegoAsset"; - let large_lego_authoring_schema_func = build_asset_func(fn_name).await?; + let large_lego_authoring_schema_func = build_asset_func(fn_name)?; // Author Resource Payload Func - let resource_payload_to_value_func = build_resource_payload_to_value_func().await?; + let resource_payload_to_value_func = build_resource_payload_to_value_func()?; let bricks = LegoBricks::new_for_odd()?; @@ -64,8 +65,7 @@ pub(crate) async fn migrate_test_exclusive_schema_large_odd_lego( .name(schema_name) .category("test exclusive") .category_name(schema_name) - .build() - .expect("schema spec data build"), + .build()?, ) .variant( SchemaVariantSpec::builder() @@ -77,8 +77,7 @@ pub(crate) async fn migrate_test_exclusive_schema_large_odd_lego( .color("#ffffff") .func_unique_id(&large_lego_authoring_schema_func.unique_id) .component_type(ComponentType::ConfigurationFrameUp) - .build() - .expect("build variant spec data"), + .build()?, ) .domain_prop(bricks.domain_name_prop) .domain_prop(bricks.domain_one_prop) @@ -140,8 +139,8 @@ pub(crate) async fn migrate_test_exclusive_schema_large_even_lego( large_lego_builder .name(schema_name) - .version(crate::schemas::PKG_VERSION) - .created_by(crate::schemas::PKG_CREATED_BY); + .version(PKG_VERSION) + .created_by(PKG_CREATED_BY); let identity_func_spec = create_identity_func()?; @@ -169,10 +168,10 @@ pub(crate) async fn migrate_test_exclusive_schema_large_even_lego( // Create Scaffold Func let fn_name = "test:scaffoldLargeLegoAsset"; - let large_lego_authoring_schema_func = build_asset_func(fn_name).await?; + let large_lego_authoring_schema_func = build_asset_func(fn_name)?; // Author Resource Payload Func - let resource_payload_to_value_func = build_resource_payload_to_value_func().await?; + let resource_payload_to_value_func = build_resource_payload_to_value_func()?; let bricks = LegoBricks::new_for_even()?; @@ -183,8 +182,7 @@ pub(crate) async fn migrate_test_exclusive_schema_large_even_lego( .name(schema_name) .category("test exclusive") .category_name(schema_name) - .build() - .expect("schema spec data build"), + .build()?, ) .variant( SchemaVariantSpec::builder() @@ -196,8 +194,7 @@ pub(crate) async fn migrate_test_exclusive_schema_large_even_lego( .color("#ffffff") .func_unique_id(&large_lego_authoring_schema_func.unique_id) .component_type(ComponentType::ConfigurationFrameUp) - .build() - .expect("build variant spec data"), + .build()?, ) .domain_prop(bricks.domain_name_prop) .domain_prop(bricks.domain_one_prop) diff --git a/lib/dal-test/src/schemas/test_exclusive_lego_schemas/test_exclusive_schema_lego_medium.rs b/lib/dal-test/src/test_exclusive_schemas/legos/medium.rs similarity index 91% rename from lib/dal-test/src/schemas/test_exclusive_lego_schemas/test_exclusive_schema_lego_medium.rs rename to lib/dal-test/src/test_exclusive_schemas/legos/medium.rs index f412bb8d01..f3664c77bb 100644 --- a/lib/dal-test/src/schemas/test_exclusive_lego_schemas/test_exclusive_schema_lego_medium.rs +++ b/lib/dal-test/src/test_exclusive_schemas/legos/medium.rs @@ -7,10 +7,11 @@ use si_pkg::{ ActionFuncSpec, PkgSpec, SchemaSpec, SchemaVariantSpec, SchemaVariantSpecData, SiPkg, }; -use crate::schemas::schema_helpers::{ - build_action_func, build_asset_func, build_resource_payload_to_value_func, create_identity_func, +use crate::test_exclusive_schemas::legos::bricks::LegoBricks; +use crate::test_exclusive_schemas::{ + build_action_func, build_asset_func, build_resource_payload_to_value_func, + create_identity_func, PKG_CREATED_BY, PKG_VERSION, }; -use crate::schemas::test_exclusive_lego_schemas::bricks::LegoBricks; pub(crate) async fn migrate_test_exclusive_schema_medium_odd_lego( ctx: &DalContext, @@ -21,8 +22,8 @@ pub(crate) async fn migrate_test_exclusive_schema_medium_odd_lego( medium_lego_builder .name(schema_name) - .version(crate::schemas::PKG_VERSION) - .created_by(crate::schemas::PKG_CREATED_BY); + .version(PKG_VERSION) + .created_by(PKG_CREATED_BY); let identity_func_spec = create_identity_func()?; @@ -50,10 +51,10 @@ pub(crate) async fn migrate_test_exclusive_schema_medium_odd_lego( // Create Scaffold Func let fn_name = "test:scaffoldMediumLegoAsset"; - let medium_lego_authoring_schema_func = build_asset_func(fn_name).await?; + let medium_lego_authoring_schema_func = build_asset_func(fn_name)?; // Author Resource Payload Func - let resource_payload_to_value_func = build_resource_payload_to_value_func().await?; + let resource_payload_to_value_func = build_resource_payload_to_value_func()?; let bricks = LegoBricks::new_for_odd()?; @@ -64,8 +65,7 @@ pub(crate) async fn migrate_test_exclusive_schema_medium_odd_lego( .name(schema_name) .category("test exclusive") .category_name(schema_name) - .build() - .expect("schema spec data build"), + .build()?, ) .variant( SchemaVariantSpec::builder() @@ -77,8 +77,7 @@ pub(crate) async fn migrate_test_exclusive_schema_medium_odd_lego( .color("#ffffff") .func_unique_id(&medium_lego_authoring_schema_func.unique_id) .component_type(ComponentType::ConfigurationFrameUp) - .build() - .expect("build variant spec data"), + .build()?, ) .domain_prop(bricks.domain_name_prop) .domain_prop(bricks.domain_one_prop) @@ -135,8 +134,8 @@ pub(crate) async fn migrate_test_exclusive_schema_medium_even_lego( medium_lego_builder .name(schema_name) - .version(crate::schemas::PKG_VERSION) - .created_by(crate::schemas::PKG_CREATED_BY); + .version(PKG_VERSION) + .created_by(PKG_CREATED_BY); let identity_func_spec = create_identity_func()?; @@ -164,10 +163,10 @@ pub(crate) async fn migrate_test_exclusive_schema_medium_even_lego( // Create Scaffold Func let fn_name = "test:scaffoldMediumLegoAsset"; - let medium_lego_authoring_schema_func = build_asset_func(fn_name).await?; + let medium_lego_authoring_schema_func = build_asset_func(fn_name)?; // Author Resource Payload Func - let resource_payload_to_value_func = build_resource_payload_to_value_func().await?; + let resource_payload_to_value_func = build_resource_payload_to_value_func()?; let bricks = LegoBricks::new_for_even()?; @@ -178,8 +177,7 @@ pub(crate) async fn migrate_test_exclusive_schema_medium_even_lego( .name(schema_name) .category("test exclusive") .category_name(schema_name) - .build() - .expect("schema spec data build"), + .build()?, ) .variant( SchemaVariantSpec::builder() @@ -191,8 +189,7 @@ pub(crate) async fn migrate_test_exclusive_schema_medium_even_lego( .color("#ffffff") .func_unique_id(&medium_lego_authoring_schema_func.unique_id) .component_type(ComponentType::ConfigurationFrameUp) - .build() - .expect("build variant spec data"), + .build()?, ) .domain_prop(bricks.domain_name_prop) .domain_prop(bricks.domain_one_prop) diff --git a/lib/dal-test/src/test_exclusive_schemas/legos/mod.rs b/lib/dal-test/src/test_exclusive_schemas/legos/mod.rs new file mode 100644 index 0000000000..5a9834500e --- /dev/null +++ b/lib/dal-test/src/test_exclusive_schemas/legos/mod.rs @@ -0,0 +1,11 @@ +pub(crate) use large::migrate_test_exclusive_schema_large_even_lego; +pub(crate) use large::migrate_test_exclusive_schema_large_odd_lego; +pub(crate) use medium::migrate_test_exclusive_schema_medium_even_lego; +pub(crate) use medium::migrate_test_exclusive_schema_medium_odd_lego; +pub(crate) use small::migrate_test_exclusive_schema_small_even_lego; +pub(crate) use small::migrate_test_exclusive_schema_small_odd_lego; + +mod bricks; +mod large; +mod medium; +mod small; diff --git a/lib/dal-test/src/schemas/test_exclusive_lego_schemas/test_exclusive_schema_lego_small.rs b/lib/dal-test/src/test_exclusive_schemas/legos/small.rs similarity index 91% rename from lib/dal-test/src/schemas/test_exclusive_lego_schemas/test_exclusive_schema_lego_small.rs rename to lib/dal-test/src/test_exclusive_schemas/legos/small.rs index 5c0e3736ac..440409eca5 100644 --- a/lib/dal-test/src/schemas/test_exclusive_lego_schemas/test_exclusive_schema_lego_small.rs +++ b/lib/dal-test/src/test_exclusive_schemas/legos/small.rs @@ -7,10 +7,11 @@ use si_pkg::{ ActionFuncSpec, PkgSpec, SchemaSpec, SchemaVariantSpec, SchemaVariantSpecData, SiPkg, }; -use crate::schemas::schema_helpers::{ - build_action_func, build_asset_func, build_resource_payload_to_value_func, create_identity_func, +use crate::test_exclusive_schemas::legos::bricks::LegoBricks; +use crate::test_exclusive_schemas::{ + build_action_func, build_asset_func, build_resource_payload_to_value_func, + create_identity_func, PKG_CREATED_BY, PKG_VERSION, }; -use crate::schemas::test_exclusive_lego_schemas::bricks::LegoBricks; pub(crate) async fn migrate_test_exclusive_schema_small_odd_lego( ctx: &DalContext, @@ -21,8 +22,8 @@ pub(crate) async fn migrate_test_exclusive_schema_small_odd_lego( small_lego_builder .name(schema_name) - .version(crate::schemas::PKG_VERSION) - .created_by(crate::schemas::PKG_CREATED_BY); + .version(PKG_VERSION) + .created_by(PKG_CREATED_BY); let identity_func_spec = create_identity_func()?; @@ -50,10 +51,10 @@ pub(crate) async fn migrate_test_exclusive_schema_small_odd_lego( // Create Scaffold Func let fn_name = "test:scaffoldSmallLegoAsset"; - let small_lego_authoring_schema_func = build_asset_func(fn_name).await?; + let small_lego_authoring_schema_func = build_asset_func(fn_name)?; // Author Resource Payload Func - let resource_payload_to_value_func = build_resource_payload_to_value_func().await?; + let resource_payload_to_value_func = build_resource_payload_to_value_func()?; let bricks = LegoBricks::new_for_odd()?; @@ -64,8 +65,7 @@ pub(crate) async fn migrate_test_exclusive_schema_small_odd_lego( .name(schema_name) .category("test exclusive") .category_name(schema_name) - .build() - .expect("schema spec data build"), + .build()?, ) .variant( SchemaVariantSpec::builder() @@ -77,8 +77,7 @@ pub(crate) async fn migrate_test_exclusive_schema_small_odd_lego( .color("#ffffff") .func_unique_id(&small_lego_authoring_schema_func.unique_id) .component_type(ComponentType::ConfigurationFrameUp) - .build() - .expect("build variant spec data"), + .build()?, ) .domain_prop(bricks.domain_name_prop) .domain_prop(bricks.domain_one_prop) @@ -132,8 +131,8 @@ pub(crate) async fn migrate_test_exclusive_schema_small_even_lego( small_lego_builder .name(schema_name) - .version(crate::schemas::PKG_VERSION) - .created_by(crate::schemas::PKG_CREATED_BY); + .version(PKG_VERSION) + .created_by(PKG_CREATED_BY); let identity_func_spec = create_identity_func()?; @@ -161,10 +160,10 @@ pub(crate) async fn migrate_test_exclusive_schema_small_even_lego( // Create Scaffold Func let fn_name = "test:scaffoldSmallLegoAsset"; - let small_lego_authoring_schema_func = build_asset_func(fn_name).await?; + let small_lego_authoring_schema_func = build_asset_func(fn_name)?; // Author Resource Payload Func - let resource_payload_to_value_func = build_resource_payload_to_value_func().await?; + let resource_payload_to_value_func = build_resource_payload_to_value_func()?; let bricks = LegoBricks::new_for_even()?; @@ -175,8 +174,7 @@ pub(crate) async fn migrate_test_exclusive_schema_small_even_lego( .name(schema_name) .category("test exclusive") .category_name(schema_name) - .build() - .expect("schema spec data build"), + .build()?, ) .variant( SchemaVariantSpec::builder() @@ -188,8 +186,7 @@ pub(crate) async fn migrate_test_exclusive_schema_small_even_lego( .color("#ffffff") .func_unique_id(&small_lego_authoring_schema_func.unique_id) .component_type(ComponentType::ConfigurationFrameUp) - .build() - .expect("build variant spec data"), + .build()?, ) .domain_prop(bricks.domain_name_prop) .domain_prop(bricks.domain_one_prop) diff --git a/lib/dal-test/src/test_exclusive_schemas/mod.rs b/lib/dal-test/src/test_exclusive_schemas/mod.rs new file mode 100644 index 0000000000..5840066475 --- /dev/null +++ b/lib/dal-test/src/test_exclusive_schemas/mod.rs @@ -0,0 +1,160 @@ +use category_pirate::migrate_test_exclusive_schema_pet_shop; +use category_pirate::migrate_test_exclusive_schema_pirate; +use category_validated::migrate_test_exclusive_schema_bad_validations; +use category_validated::migrate_test_exclusive_schema_validated_input; +use category_validated::migrate_test_exclusive_schema_validated_output; +use dal::builtins::schema; +use dal::func::argument::FuncArgumentKind; +use dal::func::intrinsics::IntrinsicFunc; +use dal::{BuiltinsError, BuiltinsResult, DalContext}; +use dummy_secret::migrate_test_exclusive_schema_dummy_secret; +use fallout::migrate_test_exclusive_schema_fallout; +use katy_perry::migrate_test_exclusive_schema_katy_perry; +use legos::migrate_test_exclusive_schema_large_even_lego; +use legos::migrate_test_exclusive_schema_large_odd_lego; +use legos::migrate_test_exclusive_schema_medium_even_lego; +use legos::migrate_test_exclusive_schema_medium_odd_lego; +use legos::migrate_test_exclusive_schema_small_even_lego; +use legos::migrate_test_exclusive_schema_small_odd_lego; +use si_pkg::{ + FuncArgumentSpec, FuncSpec, FuncSpecBackendKind, FuncSpecBackendResponseType, FuncSpecData, +}; +use starfield::migrate_test_exclusive_schema_etoiles; +use starfield::migrate_test_exclusive_schema_morningstar; +use starfield::migrate_test_exclusive_schema_starfield; +use swifty::migrate_test_exclusive_schema_swifty; + +mod category_pirate; +mod category_validated; +mod dummy_secret; +mod fallout; +mod katy_perry; +mod legos; +mod starfield; +mod swifty; + +const PKG_VERSION: &str = "2019-06-03"; +const PKG_CREATED_BY: &str = "System Initiative"; +const SI_AWS_EC2_PKG: &str = "si-aws-ec2-2023-09-26.sipkg"; +const SI_DOCKER_IMAGE_PKG: &str = "si-docker-image-2023-09-13.sipkg"; +const SI_COREOS_PKG: &str = "si-coreos-2023-09-13.sipkg"; + +pub(crate) async fn migrate(ctx: &DalContext) -> BuiltinsResult<()> { + schema::migrate_pkg(ctx, SI_DOCKER_IMAGE_PKG, None).await?; + schema::migrate_pkg(ctx, SI_COREOS_PKG, None).await?; + schema::migrate_pkg(ctx, SI_AWS_EC2_PKG, None).await?; + migrate_test_exclusive_schema_starfield(ctx).await?; + migrate_test_exclusive_schema_etoiles(ctx).await?; + migrate_test_exclusive_schema_morningstar(ctx).await?; + migrate_test_exclusive_schema_fallout(ctx).await?; + migrate_test_exclusive_schema_dummy_secret(ctx).await?; + migrate_test_exclusive_schema_swifty(ctx).await?; + migrate_test_exclusive_schema_katy_perry(ctx).await?; + migrate_test_exclusive_schema_pirate(ctx).await?; + migrate_test_exclusive_schema_pet_shop(ctx).await?; + migrate_test_exclusive_schema_validated_input(ctx).await?; + migrate_test_exclusive_schema_validated_output(ctx).await?; + migrate_test_exclusive_schema_bad_validations(ctx).await?; + migrate_test_exclusive_schema_large_odd_lego(ctx).await?; + migrate_test_exclusive_schema_large_even_lego(ctx).await?; + migrate_test_exclusive_schema_medium_even_lego(ctx).await?; + migrate_test_exclusive_schema_medium_odd_lego(ctx).await?; + migrate_test_exclusive_schema_small_odd_lego(ctx).await?; + migrate_test_exclusive_schema_small_even_lego(ctx).await?; + Ok(()) +} + +fn create_identity_func() -> BuiltinsResult { + Ok(IntrinsicFunc::Identity.to_spec()?) +} + +fn build_resource_payload_to_value_func() -> BuiltinsResult { + let resource_payload_to_value_func_code = "async function main(arg: Input): Promise {\ + return arg.payload ?? {}; + }"; + let fn_name = "test:resourcePayloadToValue"; + let resource_payload_to_value_func = FuncSpec::builder() + .name(fn_name) + .unique_id(fn_name) + .data( + FuncSpecData::builder() + .name(fn_name) + .code_plaintext(resource_payload_to_value_func_code) + .handler("main") + .backend_kind(FuncSpecBackendKind::JsAttribute) + .response_type(FuncSpecBackendResponseType::Json) + .build()?, + ) + .argument( + FuncArgumentSpec::builder() + .name("payload") + .kind(FuncArgumentKind::Object) + .build()?, + ) + .build()?; + + Ok(resource_payload_to_value_func) +} + +fn build_action_func(code: &str, fn_name: &str) -> Result { + let func = FuncSpec::builder() + .name(fn_name) + .unique_id(fn_name) + .data( + FuncSpecData::builder() + .name(fn_name) + .code_plaintext(code) + .handler("main") + .backend_kind(FuncSpecBackendKind::JsAction) + .response_type(FuncSpecBackendResponseType::Action) + .build()?, + ) + .build()?; + + Ok(func) +} + +fn build_codegen_func(code: &str, fn_name: &str) -> BuiltinsResult { + let func = FuncSpec::builder() + .name(fn_name) + .unique_id(fn_name) + .argument( + FuncArgumentSpec::builder() + .name("domain") + .kind(FuncArgumentKind::Object) + .build()?, + ) + .data( + FuncSpecData::builder() + .name(fn_name) + .code_plaintext(code) + .handler("main") + .backend_kind(FuncSpecBackendKind::JsAttribute) + .response_type(FuncSpecBackendResponseType::CodeGeneration) + .build()?, + ) + .build()?; + + Ok(func) +} + +fn build_asset_func(fn_name: &str) -> BuiltinsResult { + let scaffold_func = "function main() {\ + return new AssetBuilder().build(); + }"; + let asset_func = FuncSpec::builder() + .name(fn_name) + .unique_id(fn_name) + .data( + FuncSpecData::builder() + .name(fn_name) + .code_plaintext(scaffold_func) + .handler("main") + .backend_kind(FuncSpecBackendKind::JsSchemaVariantDefinition) + .response_type(FuncSpecBackendResponseType::SchemaVariantDefinition) + .build()?, + ) + .build()?; + + Ok(asset_func) +} diff --git a/lib/dal-test/src/schemas/test_exclusive_schema_starfield.rs b/lib/dal-test/src/test_exclusive_schemas/starfield.rs similarity index 93% rename from lib/dal-test/src/schemas/test_exclusive_schema_starfield.rs rename to lib/dal-test/src/test_exclusive_schemas/starfield.rs index 7cbf41dc2c..db1c9e8ccc 100644 --- a/lib/dal-test/src/schemas/test_exclusive_schema_starfield.rs +++ b/lib/dal-test/src/test_exclusive_schemas/starfield.rs @@ -11,6 +11,8 @@ use si_pkg::{ SchemaVariantSpec, SchemaVariantSpecData, SiPkg, SocketSpec, SocketSpecData, SocketSpecKind, }; +use crate::test_exclusive_schemas::{PKG_CREATED_BY, PKG_VERSION}; + pub(crate) async fn migrate_test_exclusive_schema_starfield( ctx: &DalContext, ) -> BuiltinsResult<()> { @@ -20,12 +22,10 @@ pub(crate) async fn migrate_test_exclusive_schema_starfield( starfield_builder .name(schema_name) - .version(crate::schemas::PKG_VERSION) - .created_by(crate::schemas::PKG_CREATED_BY); + .version(PKG_VERSION) + .created_by(PKG_CREATED_BY); - let identity_func_spec = IntrinsicFunc::Identity - .to_spec() - .expect("create identity func spec"); + let identity_func_spec = IntrinsicFunc::Identity.to_spec()?; let starfield_create_action_code = "async function create() { return { payload: { \"poop\": true }, status: \"ok\" }; @@ -188,8 +188,7 @@ pub(crate) async fn migrate_test_exclusive_schema_starfield( .name(schema_name) .category("test exclusive") .category_name(schema_name) - .build() - .expect("schema spec data build"), + .build()?, ) .variant( SchemaVariantSpec::builder() @@ -200,8 +199,7 @@ pub(crate) async fn migrate_test_exclusive_schema_starfield( .name("v0") .color("#ffffff") .func_unique_id(&starfield_authoring_schema_func.unique_id) - .build() - .expect("build variant spec data"), + .build()?, ) .domain_prop( PropSpec::builder() @@ -427,12 +425,10 @@ pub(crate) async fn migrate_test_exclusive_schema_morningstar( morningstar_builder .name(schema_name) - .version(crate::schemas::PKG_VERSION) - .created_by(crate::schemas::PKG_CREATED_BY); + .version(PKG_VERSION) + .created_by(PKG_CREATED_BY); - let identity_func_spec = IntrinsicFunc::Identity - .to_spec() - .expect("create identity func spec"); + let identity_func_spec = IntrinsicFunc::Identity.to_spec()?; let star_func_code = "async function star(input: Input): Promise { if (!input?.stars) { @@ -453,18 +449,15 @@ pub(crate) async fn migrate_test_exclusive_schema_morningstar( .handler(star_func_name) .backend_kind(FuncSpecBackendKind::JsAttribute) .response_type(FuncSpecBackendResponseType::String) - .build() - .expect("star func data build"), + .build()?, ) .argument( FuncArgumentSpec::builder() .name("stars") .kind(FuncArgumentKind::Array) - .build() - .expect("stars arg build"), + .build()?, ) - .build() - .expect("star_func_build"); + .build()?; let morningstar_scaffold_func = "function createAsset() {\ return new AssetBuilder().build(); @@ -480,11 +473,9 @@ pub(crate) async fn migrate_test_exclusive_schema_morningstar( .handler("createAsset") .backend_kind(FuncSpecBackendKind::JsSchemaVariantDefinition) .response_type(FuncSpecBackendResponseType::SchemaVariantDefinition) - .build() - .expect("scaffold data buidl"), + .build()?, ) - .build() - .expect("scaffold func build"); + .build()?; let morningstar_schema = SchemaSpec::builder() .name(schema_name) @@ -493,8 +484,7 @@ pub(crate) async fn migrate_test_exclusive_schema_morningstar( .name(schema_name) .category("test exclusive") .category_name(schema_name) - .build() - .expect("schema spec morningstar data build"), + .build()?, ) .variant( SchemaVariantSpec::builder() @@ -505,8 +495,7 @@ pub(crate) async fn migrate_test_exclusive_schema_morningstar( .name("v0") .color("#ffffff") .func_unique_id(&morningstar_authoring_schema_func.unique_id) - .build() - .expect("sv spec data build"), + .build()?, ) .domain_prop( PropSpec::builder() @@ -518,11 +507,9 @@ pub(crate) async fn migrate_test_exclusive_schema_morningstar( .kind(AttrFuncInputSpecKind::InputSocket) .name("stars") .socket_name("naming_and_necessity") - .build() - .expect("stars prop attr input build"), + .build()?, ) - .build() - .expect("stars prop build"), + .build()?, ) .socket( SocketSpec::builder() @@ -534,25 +521,20 @@ pub(crate) async fn migrate_test_exclusive_schema_morningstar( "naming_and_necessity", ])?) .kind(SocketSpecKind::Input) - .build() - .expect("socket spec data build"), + .build()?, ) - .build() - .expect("socket spec build"), + .build()?, ) - .build() - .expect("sv spec build"), + .build()?, ) - .build() - .expect("sv build"); + .build()?; let morningstar_spec = morningstar_builder .func(identity_func_spec) .func(star_func) .func(morningstar_authoring_schema_func) .schema(morningstar_schema) - .build() - .expect("schema build"); + .build()?; let pkg = SiPkg::load_from_spec(morningstar_spec)?; @@ -568,12 +550,10 @@ pub(crate) async fn migrate_test_exclusive_schema_etoiles(ctx: &DalContext) -> B etoiles_builder .name(schema_name) - .version(crate::schemas::PKG_VERSION) - .created_by(crate::schemas::PKG_CREATED_BY); + .version(PKG_VERSION) + .created_by(PKG_CREATED_BY); - let identity_func_spec = IntrinsicFunc::Identity - .to_spec() - .expect("create identity func spec"); + let identity_func_spec = IntrinsicFunc::Identity.to_spec()?; let etoiles_scaffold_func = "function createAsset() {\ return new AssetBuilder().build(); @@ -661,8 +641,7 @@ pub(crate) async fn migrate_test_exclusive_schema_etoiles(ctx: &DalContext) -> B .name(schema_name) .category("test exclusive") .category_name(schema_name) - .build() - .expect("schema spec data build"), + .build()?, ) .variant( SchemaVariantSpec::builder() @@ -673,8 +652,7 @@ pub(crate) async fn migrate_test_exclusive_schema_etoiles(ctx: &DalContext) -> B .name("v0") .color("#ffffff") .func_unique_id(&etoiles_authoring_schema_func.unique_id) - .build() - .expect("build variant spec data"), + .build()?, ) .domain_prop( PropSpec::builder() diff --git a/lib/dal-test/src/schemas/test_exclusive_schema_swifty.rs b/lib/dal-test/src/test_exclusive_schemas/swifty.rs similarity index 94% rename from lib/dal-test/src/schemas/test_exclusive_schema_swifty.rs rename to lib/dal-test/src/test_exclusive_schemas/swifty.rs index 96a9b6a54e..bd5063324b 100644 --- a/lib/dal-test/src/schemas/test_exclusive_schema_swifty.rs +++ b/lib/dal-test/src/test_exclusive_schemas/swifty.rs @@ -1,7 +1,3 @@ -use crate::schemas::schema_helpers::{ - build_action_func, build_asset_func, build_codegen_func, build_resource_payload_to_value_func, - create_identity_func, -}; use dal::action::prototype::ActionKind; use dal::pkg::import_pkg_from_pkg; use dal::{prop::PropPath, ComponentType}; @@ -13,6 +9,11 @@ use si_pkg::{ }; use si_pkg::{LeafFunctionSpec, SchemaSpecData}; +use crate::test_exclusive_schemas::{ + build_action_func, build_asset_func, build_codegen_func, build_resource_payload_to_value_func, + create_identity_func, PKG_CREATED_BY, PKG_VERSION, +}; + pub(crate) async fn migrate_test_exclusive_schema_swifty(ctx: &DalContext) -> BuiltinsResult<()> { let mut swifty_builder = PkgSpec::builder(); @@ -20,8 +21,8 @@ pub(crate) async fn migrate_test_exclusive_schema_swifty(ctx: &DalContext) -> Bu swifty_builder .name(schema_name) - .version(crate::schemas::PKG_VERSION) - .created_by(crate::schemas::PKG_CREATED_BY); + .version(PKG_VERSION) + .created_by(PKG_CREATED_BY); let identity_func_spec = create_identity_func()?; @@ -58,10 +59,10 @@ pub(crate) async fn migrate_test_exclusive_schema_swifty(ctx: &DalContext) -> Bu // Create Scaffold Func let fn_name = "test:scaffoldSwiftyAsset"; - let swifty_authoring_schema_func = build_asset_func(fn_name).await?; + let swifty_authoring_schema_func = build_asset_func(fn_name)?; // Author Resource Payload Func - let resource_payload_to_value_func = build_resource_payload_to_value_func().await?; + let resource_payload_to_value_func = build_resource_payload_to_value_func()?; // Build CodeGen Func let codegen_fn_name = "test:generateCode"; @@ -71,7 +72,7 @@ pub(crate) async fn migrate_test_exclusive_schema_swifty(ctx: &DalContext) -> Bu code: JSON.stringify(input.domain || {}, null, 2), }; }"; - let code_gen_func = build_codegen_func(codegen_func_code, codegen_fn_name).await?; + let code_gen_func = build_codegen_func(codegen_func_code, codegen_fn_name)?; let swifty_schema = SchemaSpec::builder() .name(schema_name) @@ -80,8 +81,7 @@ pub(crate) async fn migrate_test_exclusive_schema_swifty(ctx: &DalContext) -> Bu .name(schema_name) .category("test exclusive") .category_name(schema_name) - .build() - .expect("schema spec data build"), + .build()?, ) .variant( SchemaVariantSpec::builder() @@ -93,8 +93,7 @@ pub(crate) async fn migrate_test_exclusive_schema_swifty(ctx: &DalContext) -> Bu .color("#ffffff") .func_unique_id(&swifty_authoring_schema_func.unique_id) .component_type(ComponentType::ConfigurationFrameUp) - .build() - .expect("build variant spec data"), + .build()?, ) .domain_prop( PropSpec::builder() diff --git a/lib/dal/examples/snapshot-analyzer/main.rs b/lib/dal/examples/snapshot-analyzer/main.rs index d6b28bdbfc..7c1b9de318 100644 --- a/lib/dal/examples/snapshot-analyzer/main.rs +++ b/lib/dal/examples/snapshot-analyzer/main.rs @@ -1,19 +1,13 @@ -use std::{ - collections::{BTreeMap, HashMap}, - env, - fs::File, - io::prelude::*, -}; +use std::{collections::HashMap, env, fs::File, io::prelude::*}; use si_layer_cache::db::serialize; use dal::{ workspace_snapshot::{ content_address::ContentAddressDiscriminants, - edge_weight, node_weight::{NodeWeight, NodeWeightDiscriminants}, }, - EdgeWeightKind, EdgeWeightKindDiscriminants, WorkspaceSnapshotGraph, + EdgeWeightKindDiscriminants, WorkspaceSnapshotGraph, }; use tokio::time::Instant; @@ -24,7 +18,7 @@ async fn main() -> Result<()> { let mut args = env::args(); let snap_path = args.nth(1).expect("usage: program "); - let mut snap_file = File::open(&snap_path)?; + let mut snap_file = File::open(snap_path)?; let mut snap_bytes = vec![]; snap_file.read_to_end(&mut snap_bytes)?; diff --git a/lib/dal/tests/integration_test/action.rs b/lib/dal/tests/integration_test/action.rs index bb4af14b8e..cb6a607274 100644 --- a/lib/dal/tests/integration_test/action.rs +++ b/lib/dal/tests/integration_test/action.rs @@ -9,7 +9,9 @@ use pretty_assertions_sorted::assert_eq; #[test] async fn prototype_id(ctx: &mut DalContext) { - let component = create_component_for_schema_name(ctx, "swifty", "shake it off").await; + let component = create_component_for_schema_name(ctx, "swifty", "shake it off") + .await + .expect("could not create component"); let variant_id = Component::schema_variant_id(ctx, component.id()) .await .expect("find variant id for component"); @@ -44,7 +46,9 @@ async fn prototype_id(ctx: &mut DalContext) { #[test] async fn component(ctx: &mut DalContext) { - let component = create_component_for_schema_name(ctx, "swifty", "shake it off").await; + let component = create_component_for_schema_name(ctx, "swifty", "shake it off") + .await + .expect("could not create component"); let variant_id = Component::schema_variant_id(ctx, component.id()) .await .expect("find variant id for component"); @@ -77,7 +81,9 @@ async fn component(ctx: &mut DalContext) { #[test] async fn get_by_id(ctx: &mut DalContext) { - let component = create_component_for_schema_name(ctx, "swifty", "shake it off").await; + let component = create_component_for_schema_name(ctx, "swifty", "shake it off") + .await + .expect("could not create component"); let variant_id = Component::schema_variant_id(ctx, component.id()) .await .expect("find variant id for component"); @@ -111,7 +117,9 @@ async fn get_by_id(ctx: &mut DalContext) { #[test] async fn set_state(ctx: &mut DalContext) { - let component = create_component_for_schema_name(ctx, "swifty", "shake it off").await; + let component = create_component_for_schema_name(ctx, "swifty", "shake it off") + .await + .expect("could not create component"); let variant_id = Component::schema_variant_id(ctx, component.id()) .await .expect("find variant id for component"); @@ -141,7 +149,9 @@ async fn set_state(ctx: &mut DalContext) { #[test] async fn run(ctx: &mut DalContext) { - let component = create_component_for_schema_name(ctx, "swifty", "shake it off").await; + let component = create_component_for_schema_name(ctx, "swifty", "shake it off") + .await + .expect("could not create component"); let variant_id = Component::schema_variant_id(ctx, component.id()) .await .expect("find variant id for component"); @@ -166,7 +176,9 @@ async fn auto_queue_creation(ctx: &mut DalContext) { // ====================================================== // Creating a component should enqueue a create action // ====================================================== - let component = create_component_for_schema_name(ctx, "swifty", "jack antonoff").await; + let component = create_component_for_schema_name(ctx, "swifty", "jack antonoff") + .await + .expect("could not create component"); ChangeSetTestHelpers::commit_and_update_snapshot_to_visibility(ctx) .await .expect("could not commit and update snapshot to visibility"); @@ -215,7 +227,9 @@ async fn auto_queue_update_and_destroy(ctx: &mut DalContext) { // ====================================================== // Creating a component should enqueue a create action // ====================================================== - let component = create_component_for_schema_name(ctx, "swifty", "jack antonoff").await; + let component = create_component_for_schema_name(ctx, "swifty", "jack antonoff") + .await + .expect("could not create component"); ChangeSetTestHelpers::commit_and_update_snapshot_to_visibility(ctx) .await .expect("commit and update snapshot to visibility"); diff --git a/lib/dal/tests/integration_test/component.rs b/lib/dal/tests/integration_test/component.rs index 136b84bfe8..3e70fe59c7 100644 --- a/lib/dal/tests/integration_test/component.rs +++ b/lib/dal/tests/integration_test/component.rs @@ -22,7 +22,9 @@ mod set_type; mod upgrade; #[test] async fn update_and_insert_and_update(ctx: &mut DalContext) { - let component = create_component_for_schema_name(ctx, "Docker Image", "a tulip in a cup").await; + let component = create_component_for_schema_name(ctx, "Docker Image", "a tulip in a cup") + .await + .expect("could not create component"); let variant_id = Component::schema_variant_id(ctx, component.id()) .await .expect("find variant id for component"); @@ -225,7 +227,9 @@ async fn create_and_determine_lineage(ctx: &DalContext) { #[test] async fn through_the_wormholes_simple(ctx: &mut DalContext) { let name = "across the universe"; - let component = create_component_for_schema_name(ctx, "starfield", name).await; + let component = create_component_for_schema_name(ctx, "starfield", name) + .await + .expect("could not create component"); let variant_id = Component::schema_variant_id(ctx, component.id()) .await .expect("find variant id for component"); @@ -400,7 +404,9 @@ async fn through_the_wormholes_simple(ctx: &mut DalContext) { #[test] async fn through_the_wormholes_child_value_reactivity(ctx: &mut DalContext) { let name = "across the universe"; - let component = create_component_for_schema_name(ctx, "starfield", name).await; + let component = create_component_for_schema_name(ctx, "starfield", name) + .await + .expect("could not create component"); let variant_id = Component::schema_variant_id(ctx, component.id()) .await .expect("find variant id for component"); @@ -560,13 +566,17 @@ async fn through_the_wormholes_child_value_reactivity(ctx: &mut DalContext) { #[test] async fn through_the_wormholes_dynamic_child_value_reactivity(ctx: &mut DalContext) { let etoiles_name = "À la belle étoile"; - let etoiles_component = create_component_for_schema_name(ctx, "etoiles", etoiles_name).await; + let etoiles_component = create_component_for_schema_name(ctx, "etoiles", etoiles_name) + .await + .expect("could not create component"); let etoiles_variant_id = Component::schema_variant_id(ctx, etoiles_component.id()) .await .expect("find variant id for etoiles component"); let morningstar_name = "hesperus is phosphorus"; let morningstar_component = - create_component_for_schema_name(ctx, "morningstar", morningstar_name).await; + create_component_for_schema_name(ctx, "morningstar", morningstar_name) + .await + .expect("could not create component"); let morningstar_variant_id = Component::schema_variant_id(ctx, morningstar_component.id()) .await .expect("find variant id for morningstar component"); @@ -657,7 +667,8 @@ async fn through_the_wormholes_dynamic_child_value_reactivity(ctx: &mut DalConte morningstar_component.id(), "naming_and_necessity", ) - .await; + .await + .expect("could not connect components with socket names"); ChangeSetTestHelpers::commit_and_update_snapshot_to_visibility(ctx) .await @@ -692,7 +703,9 @@ async fn through_the_wormholes_dynamic_child_value_reactivity(ctx: &mut DalConte #[test] async fn set_the_universe(ctx: &mut DalContext) { - let component = create_component_for_schema_name(ctx, "starfield", "across the universe").await; + let component = create_component_for_schema_name(ctx, "starfield", "across the universe") + .await + .expect("could not create component"); let variant_id = Component::schema_variant_id(ctx, component.id()) .await .expect("find variant id for component"); @@ -1171,11 +1184,15 @@ async fn undoing_deletion_updates_inputs(ctx: &mut DalContext) { async fn paste_component(ctx: &mut DalContext) { let pirate_name = "Long John Silver"; let parrot_name = "Captain Flint"; - let pirate_component = create_component_for_schema_name(ctx, "pirate", pirate_name).await; + let pirate_component = create_component_for_schema_name(ctx, "pirate", pirate_name) + .await + .expect("could not create component"); let parrots_path = &["root", "domain", "parrot_names"]; - let pet_shop_component = create_component_for_schema_name(ctx, "pet_shop", "Petopia").await; + let pet_shop_component = create_component_for_schema_name(ctx, "pet_shop", "Petopia") + .await + .expect("could not create component"); // set value on source component { @@ -1198,7 +1215,8 @@ async fn paste_component(ctx: &mut DalContext) { pirate_component.id(), "parrot_names", ) - .await; + .await + .expect("could not connect components with socket names"); ChangeSetTestHelpers::commit_and_update_snapshot_to_visibility(ctx) .await @@ -1254,7 +1272,9 @@ async fn paste_component(ctx: &mut DalContext) { #[test] async fn delete(ctx: &mut DalContext) { - let component = create_component_for_schema_name(ctx, "swifty", "shake it off").await; + let component = create_component_for_schema_name(ctx, "swifty", "shake it off") + .await + .expect("could not create component"); ChangeSetTestHelpers::commit_and_update_snapshot_to_visibility(ctx) .await @@ -1269,7 +1289,9 @@ async fn delete(ctx: &mut DalContext) { #[test] async fn delete_enqueues_destroy_action(ctx: &mut DalContext) { - let component = create_component_for_schema_name(ctx, "VPC", "component with destroy").await; + let component = create_component_for_schema_name(ctx, "VPC", "component with destroy") + .await + .expect("could not create component"); let resource_data = ResourceData::new( ResourceStatus::Ok, Some(serde_json::json![{"resource": "something"}]), @@ -1313,7 +1335,9 @@ async fn delete_enqueues_destroy_action(ctx: &mut DalContext) { #[test] async fn delete_on_already_to_delete_does_not_enqueue_destroy_action(ctx: &mut DalContext) { - let component = create_component_for_schema_name(ctx, "VPC", "component with destroy").await; + let component = create_component_for_schema_name(ctx, "VPC", "component with destroy") + .await + .expect("could not create component"); let resource_data = ResourceData::new( ResourceStatus::Ok, Some(serde_json::json![{"resource": "something"}]), diff --git a/lib/dal/tests/integration_test/component/debug.rs b/lib/dal/tests/integration_test/component/debug.rs index 5a8dcca4cc..55814633d3 100644 --- a/lib/dal/tests/integration_test/component/debug.rs +++ b/lib/dal/tests/integration_test/component/debug.rs @@ -9,8 +9,9 @@ use pretty_assertions_sorted::assert_eq; #[test] async fn get_debug_view(ctx: &mut DalContext) { //create a new component for starfield schema - let component: Component = - create_component_for_schema_name(ctx, "starfield", "new component").await; + let component: Component = create_component_for_schema_name(ctx, "starfield", "new component") + .await + .expect("could not create component"); ChangeSetTestHelpers::commit_and_update_snapshot_to_visibility(ctx) .await .expect("could not commit and update snapshot to visibility"); diff --git a/lib/dal/tests/integration_test/component/get_code.rs b/lib/dal/tests/integration_test/component/get_code.rs index 758f1e26a9..5561f5229a 100644 --- a/lib/dal/tests/integration_test/component/get_code.rs +++ b/lib/dal/tests/integration_test/component/get_code.rs @@ -7,7 +7,9 @@ use pretty_assertions_sorted::assert_eq; #[test] async fn get_code_json_lang(ctx: &mut DalContext) { - let component = create_component_for_schema_name(ctx, "swifty", "shake it off").await; + let component = create_component_for_schema_name(ctx, "swifty", "shake it off") + .await + .expect("could not create component"); ChangeSetTestHelpers::commit_and_update_snapshot_to_visibility(ctx) .await @@ -35,7 +37,9 @@ async fn get_code_json_lang(ctx: &mut DalContext) { #[test] async fn get_code_yaml_and_string(ctx: &mut DalContext) { let component = - create_component_for_schema_name(ctx, "katy perry", "all codegen and no actions").await; + create_component_for_schema_name(ctx, "katy perry", "all codegen and no actions") + .await + .expect("could not create component"); ChangeSetTestHelpers::commit_and_update_snapshot_to_visibility(ctx) .await @@ -73,7 +77,9 @@ async fn get_code_yaml_and_string(ctx: &mut DalContext) { #[test] async fn get_code_no_codegen_funcs(ctx: &mut DalContext) { let starfield_component = - create_component_for_schema_name(ctx, "starfield", "no codegen funcs here").await; + create_component_for_schema_name(ctx, "starfield", "no codegen funcs here") + .await + .expect("could not create component"); ChangeSetTestHelpers::commit_and_update_snapshot_to_visibility(ctx) .await .expect("could not commit and update snapshot to visibility"); diff --git a/lib/dal/tests/integration_test/component/get_diff.rs b/lib/dal/tests/integration_test/component/get_diff.rs index 51f401d0b7..26129a5cdf 100644 --- a/lib/dal/tests/integration_test/component/get_diff.rs +++ b/lib/dal/tests/integration_test/component/get_diff.rs @@ -9,7 +9,9 @@ use serde_json::Value; #[test] async fn get_diff_new_component(ctx: &mut DalContext) { let starfield_component = - create_component_for_schema_name(ctx, "starfield", "this is a new component").await; + create_component_for_schema_name(ctx, "starfield", "this is a new component") + .await + .expect("could not create component"); ChangeSetTestHelpers::commit_and_update_snapshot_to_visibility(ctx) .await .expect("could not commit and update snapshot to visibility"); @@ -36,7 +38,9 @@ async fn get_diff_new_component(ctx: &mut DalContext) { #[test] async fn get_diff_component_no_changes_from_head(ctx: &mut DalContext) { let starfield_component = - create_component_for_schema_name(ctx, "starfield", "this is a new component").await; + create_component_for_schema_name(ctx, "starfield", "this is a new component") + .await + .expect("could not create component"); ChangeSetTestHelpers::commit_and_update_snapshot_to_visibility(ctx) .await .expect("could not commit and update snapshot to visibility"); @@ -85,7 +89,9 @@ async fn get_diff_component_no_changes_from_head(ctx: &mut DalContext) { #[test] async fn get_diff_component_change_comp_type(ctx: &mut DalContext) { let starfield_component = - create_component_for_schema_name(ctx, "starfield", "this is a new component").await; + create_component_for_schema_name(ctx, "starfield", "this is a new component") + .await + .expect("could not create component"); ChangeSetTestHelpers::commit_and_update_snapshot_to_visibility(ctx) .await .expect("could not commit"); diff --git a/lib/dal/tests/integration_test/component/set_type.rs b/lib/dal/tests/integration_test/component/set_type.rs index fcada7c50d..a82925ad07 100644 --- a/lib/dal/tests/integration_test/component/set_type.rs +++ b/lib/dal/tests/integration_test/component/set_type.rs @@ -4,7 +4,9 @@ use dal_test::test; #[test] async fn set_type(ctx: &mut DalContext) { - let component = create_component_for_schema_name(ctx, "starfield", "black star").await; + let component = create_component_for_schema_name(ctx, "starfield", "black star") + .await + .expect("could not create component"); pretty_assertions_sorted::assert_eq!( component.get_type(ctx).await.expect("could not get type"), diff --git a/lib/dal/tests/integration_test/component/upgrade.rs b/lib/dal/tests/integration_test/component/upgrade.rs index eb36f7bda1..de22730ae2 100644 --- a/lib/dal/tests/integration_test/component/upgrade.rs +++ b/lib/dal/tests/integration_test/component/upgrade.rs @@ -111,7 +111,9 @@ async fn upgrade_component(ctx: &mut DalContext) { // Add a component to the diagram let initial_component = - create_component_for_schema_name(ctx, my_asset_schema.name.clone(), "demo component").await; + create_component_for_schema_name(ctx, my_asset_schema.name.clone(), "demo component") + .await + .expect("could not create component"); let initial_diagram = Diagram::assemble(ctx) .await .expect("could not assemble diagram"); diff --git a/lib/dal/tests/integration_test/connection.rs b/lib/dal/tests/integration_test/connection.rs index 9aa0f0ddbd..5eed82da58 100644 --- a/lib/dal/tests/integration_test/connection.rs +++ b/lib/dal/tests/integration_test/connection.rs @@ -11,8 +11,12 @@ use serde::Deserialize; #[test] async fn make_multiple_trees(ctx: &mut DalContext) { // create 2 even legos - let even_lego_1 = create_component_for_schema_name(ctx, "large even lego", "even lego 1").await; - let even_lego_2 = create_component_for_schema_name(ctx, "large even lego", "even lego 2").await; + let even_lego_1 = create_component_for_schema_name(ctx, "large even lego", "even lego 1") + .await + .expect("could not create component"); + let even_lego_2 = create_component_for_schema_name(ctx, "large even lego", "even lego 2") + .await + .expect("could not create component"); let even_sv_id = even_lego_1 .schema_variant(ctx) @@ -28,8 +32,12 @@ async fn make_multiple_trees(ctx: &mut DalContext) { .await .expect("could not commit and update snapshot to visibility"); //create 2 odd legos - let odd_lego_1 = create_component_for_schema_name(ctx, "large odd lego", "odd lego 1").await; - let odd_lego_2 = create_component_for_schema_name(ctx, "large odd lego", "odd lego 2").await; + let odd_lego_1 = create_component_for_schema_name(ctx, "large odd lego", "odd lego 1") + .await + .expect("could not create component"); + let odd_lego_2 = create_component_for_schema_name(ctx, "large odd lego", "odd lego 2") + .await + .expect("could not create component"); let odd_sv = odd_lego_1 .schema_variant(ctx) .await @@ -84,12 +92,15 @@ async fn make_multiple_trees(ctx: &mut DalContext) { #[test] async fn make_chain_remove_middle(ctx: &mut DalContext) { // make chain of odd lego 1 -> even lego 1 -> odd lego 2 - let odd_component_1 = - create_component_for_schema_name(ctx, "large odd lego", "odd lego 1").await; - let even_component_1 = - create_component_for_schema_name(ctx, "large even lego", "even lego 1").await; - let odd_component_2 = - create_component_for_schema_name(ctx, "large odd lego", "odd lego 2").await; + let odd_component_1 = create_component_for_schema_name(ctx, "large odd lego", "odd lego 1") + .await + .expect("could not create component"); + let even_component_1 = create_component_for_schema_name(ctx, "large even lego", "even lego 1") + .await + .expect("could not create component"); + let odd_component_2 = create_component_for_schema_name(ctx, "large odd lego", "odd lego 2") + .await + .expect("could not create component"); ChangeSetTestHelpers::commit_and_update_snapshot_to_visibility(ctx) .await .expect("could not commit and update snapshot to visibility"); @@ -426,16 +437,22 @@ async fn connect_and_disconnect_components_explicit_connection(ctx: &mut DalCont async fn connect_to_one_destination_with_multiple_candidates_of_same_schema_variant_on_diagram( ctx: &mut DalContext, ) { - let source = create_component_for_schema_name(ctx, "fallout", "source").await; + let source = create_component_for_schema_name(ctx, "fallout", "source") + .await + .expect("could not create component"); let source_sv_id = Component::schema_variant_id(ctx, source.id()) .await .expect("find variant id for component"); - let destination = create_component_for_schema_name(ctx, "starfield", "destination").await; + let destination = create_component_for_schema_name(ctx, "starfield", "destination") + .await + .expect("could not create component"); let destination_sv_id = Component::schema_variant_id(ctx, destination.id()) .await .expect("find variant id for component"); - create_component_for_schema_name(ctx, "starfield", "not destination").await; + create_component_for_schema_name(ctx, "starfield", "not destination") + .await + .expect("could not create component"); ChangeSetTestHelpers::commit_and_update_snapshot_to_visibility(ctx) .await diff --git a/lib/dal/tests/integration_test/frame.rs b/lib/dal/tests/integration_test/frame.rs index faf2dfe47a..ba583158e6 100644 --- a/lib/dal/tests/integration_test/frame.rs +++ b/lib/dal/tests/integration_test/frame.rs @@ -19,9 +19,13 @@ mod with_actions; async fn frames_and_connections(ctx: &mut DalContext) { //create 1 components and draw edges to another 1 let first_component = - create_component_for_schema_name(ctx, "small even lego", "first_component").await; + create_component_for_schema_name(ctx, "small even lego", "first_component") + .await + .expect("could not create component"); let second_component = - create_component_for_schema_name(ctx, "small odd lego", "second_component").await; + create_component_for_schema_name(ctx, "small odd lego", "second_component") + .await + .expect("could not create component"); //connect them connect_components_with_socket_names( @@ -31,14 +35,16 @@ async fn frames_and_connections(ctx: &mut DalContext) { second_component.id(), "one", ) - .await; + .await + .expect("could not connect components with socket names"); update_attribute_value_for_component( ctx, first_component.id(), &["root", "domain", "one"], serde_json::json!["1"], ) - .await; + .await + .expect("could not update attribute value"); ChangeSetTestHelpers::commit_and_update_snapshot_to_visibility(ctx) .await .expect("could not commit"); @@ -46,6 +52,7 @@ async fn frames_and_connections(ctx: &mut DalContext) { // make sure the value propagates let input_value = get_component_input_socket_value(ctx, second_component.id(), "one") .await + .expect("could not get component input socket value") .expect("has value"); assert_eq!( "1", // expected @@ -54,9 +61,13 @@ async fn frames_and_connections(ctx: &mut DalContext) { //create 2 of the same schema variant, only use frames to connect them //create 1 components and draw edges to another 1 let third_component = - create_component_for_schema_name(ctx, "small even lego", "third_component").await; + create_component_for_schema_name(ctx, "small even lego", "third_component") + .await + .expect("could not create component"); let fourth_component = - create_component_for_schema_name(ctx, "small odd lego", "fourth_component").await; + create_component_for_schema_name(ctx, "small odd lego", "fourth_component") + .await + .expect("could not create component"); fourth_component .set_type(ctx, ComponentType::ConfigurationFrameUp) .await @@ -74,13 +85,15 @@ async fn frames_and_connections(ctx: &mut DalContext) { &["root", "domain", "one"], serde_json::json!["2"], ) - .await; + .await + .expect("could not update attribute value"); ChangeSetTestHelpers::commit_and_update_snapshot_to_visibility(ctx) .await .expect("could not commit"); // values should propagate let input_value = get_component_input_socket_value(ctx, fourth_component.id(), "one") .await + .expect("could not get input socket value") .expect("has value"); assert_eq!( "2", // expected @@ -464,13 +477,21 @@ async fn simple_frames(ctx: &mut DalContext) { #[test] async fn output_sockets_can_have_both(ctx: &mut DalContext) { // create an even frame - let even_frame = create_component_for_schema_name(ctx, "large even lego", "even").await; + let even_frame = create_component_for_schema_name(ctx, "large even lego", "even") + .await + .expect("could not create component"); - let _ = even_frame + even_frame .set_type(ctx, ComponentType::ConfigurationFrameDown) - .await; - let odd_component = create_component_for_schema_name(ctx, "large odd lego", "odd1").await; - let _ = odd_component.set_type(ctx, ComponentType::Component).await; + .await + .expect("could not set type"); + let odd_component = create_component_for_schema_name(ctx, "large odd lego", "odd1") + .await + .expect("could not create component"); + odd_component + .set_type(ctx, ComponentType::Component) + .await + .expect("could not set type"); Frame::upsert_parent(ctx, odd_component.id(), even_frame.id()) .await .expect("could not upsert parent"); @@ -491,13 +512,17 @@ async fn output_sockets_can_have_both(ctx: &mut DalContext) { .expect("could not commit and update snapshot to visibility"); // create another odd component, but manually connect to the frame (not a child!) - let odd_component_2 = create_component_for_schema_name(ctx, "large odd lego", "odd2").await; - let _ = odd_component_2 + let odd_component_2 = create_component_for_schema_name(ctx, "large odd lego", "odd2") + .await + .expect("could not create component"); + odd_component_2 .set_type(ctx, ComponentType::Component) - .await; + .await + .expect("could not set type"); connect_components_with_socket_names(ctx, even_frame.id(), "one", odd_component_2.id(), "one") - .await; + .await + .expect("could not connect components with socket names"); ChangeSetTestHelpers::commit_and_update_snapshot_to_visibility(ctx) .await .expect("could not commit and update snapshot to visibility"); @@ -556,14 +581,22 @@ async fn output_sockets_can_have_both(ctx: &mut DalContext) { #[test] async fn simple_down_frames_no_nesting(ctx: &mut DalContext) { - let even_frame = create_component_for_schema_name(ctx, "large even lego", "even").await; + let even_frame = create_component_for_schema_name(ctx, "large even lego", "even") + .await + .expect("could not create component"); let even_frame_component_id = even_frame.id(); - let _ = even_frame + even_frame .set_type(ctx, ComponentType::ConfigurationFrameDown) - .await; + .await + .expect("could not set type"); - let odd_component = create_component_for_schema_name(ctx, "large odd lego", "odd").await; - let _ = odd_component.set_type(ctx, ComponentType::Component).await; + let odd_component = create_component_for_schema_name(ctx, "large odd lego", "odd") + .await + .expect("could not create component"); + odd_component + .set_type(ctx, ComponentType::Component) + .await + .expect("could not set type"); Frame::upsert_parent(ctx, odd_component.id(), even_frame.id()) .await .expect("could not upsert parent"); @@ -574,7 +607,8 @@ async fn simple_down_frames_no_nesting(ctx: &mut DalContext) { &["root", "domain", "one"], serde_json::json!["1"], ) - .await; + .await + .expect("could not update attribute value"); ChangeSetTestHelpers::commit_and_update_snapshot_to_visibility(ctx) .await @@ -582,11 +616,13 @@ async fn simple_down_frames_no_nesting(ctx: &mut DalContext) { // the output socket value is updated with 1 let output_value = get_component_output_socket_value(ctx, even_frame_component_id, "one") .await + .expect("could not get output socket value") .expect("has value"); assert_eq!(output_value, serde_json::json!("1")); let input_value = get_component_input_socket_value(ctx, odd_component.id(), "one") .await + .expect("could not get input socket value") .expect("has value"); assert_eq!(input_value, serde_json::json!("1")); } @@ -603,33 +639,47 @@ async fn down_frames_moving_deeply_nested_frames(ctx: &mut DalContext) { // create first greatgrandparent let first_greatgrandparent_frame = - create_component_for_schema_name(ctx, "medium even lego", "greatgrandparent 1").await; + create_component_for_schema_name(ctx, "medium even lego", "greatgrandparent 1") + .await + .expect("could not create component"); - let _ = first_greatgrandparent_frame + first_greatgrandparent_frame .set_type(ctx, ComponentType::ConfigurationFrameDown) - .await; + .await + .expect("could not set type"); // create grandparent frame let first_grand_parent_frame = - create_component_for_schema_name(ctx, "medium odd lego", "grandparent").await; - let _ = first_grand_parent_frame + create_component_for_schema_name(ctx, "medium odd lego", "grandparent") + .await + .expect("could not create component"); + first_grand_parent_frame .set_type(ctx, ComponentType::ConfigurationFrameDown) - .await; + .await + .expect("could not set type"); // create parent frame - let parent_frame = create_component_for_schema_name(ctx, "small even lego", "parent").await; - let _ = parent_frame + let parent_frame = create_component_for_schema_name(ctx, "small even lego", "parent") + .await + .expect("could not create component"); + parent_frame .set_type(ctx, ComponentType::ConfigurationFrameDown) - .await; + .await + .expect("could not set type"); // create child components - let first_child_component = - create_component_for_schema_name(ctx, "medium odd lego", "child 1").await; - let _ = first_child_component + let first_child_component = create_component_for_schema_name(ctx, "medium odd lego", "child 1") + .await + .expect("could not create component"); + first_child_component .set_type(ctx, ComponentType::ConfigurationFrameDown) - .await; + .await + .expect("could not set type"); let second_child_component = - create_component_for_schema_name(ctx, "medium even lego", "child 2").await; - let _ = second_child_component + create_component_for_schema_name(ctx, "medium even lego", "child 2") + .await + .expect("could not create component"); + second_child_component .set_type(ctx, ComponentType::ConfigurationFrameDown) - .await; + .await + .expect("could not set type"); // upsert child into parent, parent into grandparent, grandparent into great grandparent and child into grandparent Frame::upsert_parent(ctx, first_child_component.id(), parent_frame.id()) @@ -661,7 +711,8 @@ async fn down_frames_moving_deeply_nested_frames(ctx: &mut DalContext) { &["root", "domain", "three"], serde_json::json!["3"], ) - .await; + .await + .expect("could not update attribute value"); // this value should only pass to the grandparent, the first_child has a closer match with its parent update_attribute_value_for_component( ctx, @@ -669,7 +720,8 @@ async fn down_frames_moving_deeply_nested_frames(ctx: &mut DalContext) { &["root", "domain", "one"], serde_json::json!["2"], ) - .await; + .await + .expect("could not update attribute value"); // this value should pass to the first_child update_attribute_value_for_component( ctx, @@ -677,7 +729,8 @@ async fn down_frames_moving_deeply_nested_frames(ctx: &mut DalContext) { &["root", "domain", "one"], serde_json::json!["1"], ) - .await; + .await + .expect("could not update attribute value"); // this value should pass to the second_child update_attribute_value_for_component( ctx, @@ -685,43 +738,54 @@ async fn down_frames_moving_deeply_nested_frames(ctx: &mut DalContext) { &["root", "domain", "two"], serde_json::json!["2"], ) - .await; + .await + .expect("could not update attribute value"); ChangeSetTestHelpers::commit_and_update_snapshot_to_visibility(ctx) .await .expect("could not commit and update snapshot to visibility"); // the first_component is updated with 3 let input_value = get_component_input_socket_value(ctx, first_child_component.id(), "three") .await + .expect("could not get input socket value") .expect("is some"); assert_eq!(input_value, serde_json::json!("3")); // the first_componenent is updated with 1 let input_value = get_component_input_socket_value(ctx, first_child_component.id(), "one") .await + .expect("could not get input socket value") .expect("is some"); assert_eq!(input_value, serde_json::json!("1")); // the second_component is updated with 2 let input_value = get_component_input_socket_value(ctx, second_child_component.id(), "two") .await + .expect("could not get input socket value") .expect("is some"); assert_eq!(input_value, serde_json::json!("2")); // the parent is updated with 2 let input_value = get_component_input_socket_value(ctx, parent_frame.id(), "two") .await + .expect("could not get input socket value") .expect("is some"); assert_eq!(input_value, serde_json::json!("2")); // now create the other great grandparent and grandparent frame and move the parent into it let second_greatgrandparent_frame = - create_component_for_schema_name(ctx, "medium even lego", "grandparent 2").await; + create_component_for_schema_name(ctx, "medium even lego", "grandparent 2") + .await + .expect("could not create component"); - let _ = second_greatgrandparent_frame + second_greatgrandparent_frame .set_type(ctx, ComponentType::ConfigurationFrameDown) - .await; + .await + .expect("could not set type"); let second_grand_parent_frame = - create_component_for_schema_name(ctx, "small odd lego", "grandparent").await; - let _ = second_grand_parent_frame + create_component_for_schema_name(ctx, "small odd lego", "grandparent") + .await + .expect("could not create component"); + second_grand_parent_frame .set_type(ctx, ComponentType::ConfigurationFrameDown) - .await; + .await + .expect("could not set type"); Frame::upsert_parent( ctx, second_grand_parent_frame.id(), @@ -740,17 +804,20 @@ async fn down_frames_moving_deeply_nested_frames(ctx: &mut DalContext) { assert!( get_component_input_socket_value(ctx, first_child_component.id(), "three") .await + .expect("could not get input socket value") .is_none() ); // the value coming from the first grandparent should be unset assert!( get_component_input_socket_value(ctx, second_child_component.id(), "two") .await + .expect("could not get input socket value") .is_none() ); assert!( get_component_input_socket_value(ctx, parent_frame.id(), "two") .await + .expect("could not get input socket value") .is_none() ); @@ -761,7 +828,8 @@ async fn down_frames_moving_deeply_nested_frames(ctx: &mut DalContext) { &["root", "domain", "three"], serde_json::json!["4"], ) - .await; + .await + .expect("could not update attribute value"); // this value should pass as the parent frame doesn't have an output socket for "3" update_attribute_value_for_component( ctx, @@ -769,30 +837,35 @@ async fn down_frames_moving_deeply_nested_frames(ctx: &mut DalContext) { &["root", "domain", "two"], serde_json::json!["5"], ) - .await; + .await + .expect("could not update attribute value"); ChangeSetTestHelpers::commit_and_update_snapshot_to_visibility(ctx) .await .expect("could not commit and update snapshot to visibility"); // the first_componenent still has 1 let input_value = get_component_input_socket_value(ctx, first_child_component.id(), "one") .await + .expect("could not get input socket value") .expect("is some"); assert_eq!(input_value, serde_json::json!("1")); // the component is updated with 4 let input_value = get_component_input_socket_value(ctx, first_child_component.id(), "three") .await + .expect("could not get input socket value") .expect("is some"); assert_eq!(input_value, serde_json::json!("4")); // the second component is updated with 5 let input_value = get_component_input_socket_value(ctx, second_child_component.id(), "two") .await + .expect("could not get input socket value") .expect("is some"); assert_eq!(input_value, serde_json::json!("5")); // the parent is updated with 5 let input_value = get_component_input_socket_value(ctx, parent_frame.id(), "two") .await + .expect("could not get input socket value") .expect("is some"); assert_eq!(input_value, serde_json::json!("5")); @@ -804,28 +877,39 @@ async fn up_frames_moving_deeply_nested_frames(ctx: &mut DalContext) { // create first greatgrandparent let first_greatgrandparent_frame = - create_component_for_schema_name(ctx, "medium even lego", "greatgrandparent 1").await; + create_component_for_schema_name(ctx, "medium even lego", "greatgrandparent 1") + .await + .expect("could not create component"); - let _ = first_greatgrandparent_frame + first_greatgrandparent_frame .set_type(ctx, ComponentType::Component) - .await; + .await + .expect("could not set type"); // create grandparent frame let first_grand_parent_frame = - create_component_for_schema_name(ctx, "medium odd lego", "grandparent").await; - let _ = first_grand_parent_frame + create_component_for_schema_name(ctx, "medium odd lego", "grandparent") + .await + .expect("could not create component"); + first_grand_parent_frame .set_type(ctx, ComponentType::ConfigurationFrameUp) - .await; + .await + .expect("could not set type"); // create parent frame - let parent_frame = create_component_for_schema_name(ctx, "small even lego", "parent").await; - let _ = parent_frame + let parent_frame = create_component_for_schema_name(ctx, "small even lego", "parent") + .await + .expect("could not create component"); + parent_frame .set_type(ctx, ComponentType::ConfigurationFrameUp) - .await; + .await + .expect("could not set type"); // create child components - let first_child_component = - create_component_for_schema_name(ctx, "medium odd lego", "child 1").await; - let _ = first_child_component + let first_child_component = create_component_for_schema_name(ctx, "medium odd lego", "child 1") + .await + .expect("could not create component"); + first_child_component .set_type(ctx, ComponentType::ConfigurationFrameUp) - .await; + .await + .expect("could not set type"); // upsert child into parent, parent into grandparent, grandparent into great grandparent and child into grandparent Frame::upsert_parent(ctx, parent_frame.id(), first_child_component.id()) @@ -855,7 +939,8 @@ async fn up_frames_moving_deeply_nested_frames(ctx: &mut DalContext) { &["root", "domain", "three"], serde_json::json!["3"], ) - .await; + .await + .expect("could not update attribute value"); // this value should only pass to the grandparent, the first_child has a closer match with its parent update_attribute_value_for_component( ctx, @@ -863,7 +948,8 @@ async fn up_frames_moving_deeply_nested_frames(ctx: &mut DalContext) { &["root", "domain", "one"], serde_json::json!["2"], ) - .await; + .await + .expect("could not update attribute value"); // this value should pass to the first_child update_attribute_value_for_component( ctx, @@ -871,7 +957,8 @@ async fn up_frames_moving_deeply_nested_frames(ctx: &mut DalContext) { &["root", "domain", "one"], serde_json::json!["1"], ) - .await; + .await + .expect("could not update attribute value"); // this value should pass to the second_child update_attribute_value_for_component( ctx, @@ -879,39 +966,49 @@ async fn up_frames_moving_deeply_nested_frames(ctx: &mut DalContext) { &["root", "domain", "two"], serde_json::json!["2"], ) - .await; + .await + .expect("could not update attribute value"); ChangeSetTestHelpers::commit_and_update_snapshot_to_visibility(ctx) .await .expect("could not commit and update snapshot to visibility"); // the first_component is updated with 3 let input_value = get_component_input_socket_value(ctx, first_child_component.id(), "three") .await + .expect("could not get input socket value") .expect("is some"); assert_eq!(input_value, serde_json::json!("3")); // the first_componenent is updated with 1 let input_value = get_component_input_socket_value(ctx, first_child_component.id(), "one") .await + .expect("could not get input socket value") .expect("is some"); assert_eq!(input_value, serde_json::json!("1")); // the parent is updated with 2 let input_value = get_component_input_socket_value(ctx, parent_frame.id(), "two") .await + .expect("could not get input socket value") .expect("is some"); assert_eq!(input_value, serde_json::json!("2")); // now create the other great grandparent and grandparent frame and move the parent into it let second_greatgrandparent_frame = - create_component_for_schema_name(ctx, "medium even lego", "grandparent 2").await; + create_component_for_schema_name(ctx, "medium even lego", "grandparent 2") + .await + .expect("could not create component"); - let _ = second_greatgrandparent_frame + second_greatgrandparent_frame .set_type(ctx, ComponentType::Component) - .await; + .await + .expect("could not set type"); let second_grand_parent_frame = - create_component_for_schema_name(ctx, "small odd lego", "grandparent").await; - let _ = second_grand_parent_frame + create_component_for_schema_name(ctx, "small odd lego", "grandparent") + .await + .expect("could not create component"); + second_grand_parent_frame .set_type(ctx, ComponentType::ConfigurationFrameUp) - .await; + .await + .expect("could not set type"); Frame::upsert_parent( ctx, second_greatgrandparent_frame.id(), @@ -934,12 +1031,14 @@ async fn up_frames_moving_deeply_nested_frames(ctx: &mut DalContext) { assert!( get_component_input_socket_value(ctx, first_child_component.id(), "three") .await + .expect("could not get input socket value") .is_none() ); assert!( get_component_input_socket_value(ctx, parent_frame.id(), "two") .await + .expect("could not get input socket value") .is_none() ); @@ -950,7 +1049,8 @@ async fn up_frames_moving_deeply_nested_frames(ctx: &mut DalContext) { &["root", "domain", "three"], serde_json::json!["4"], ) - .await; + .await + .expect("could not update attribute value"); // this value should pass as the parent frame doesn't have an output socket for "3" update_attribute_value_for_component( ctx, @@ -958,18 +1058,21 @@ async fn up_frames_moving_deeply_nested_frames(ctx: &mut DalContext) { &["root", "domain", "two"], serde_json::json!["5"], ) - .await; + .await + .expect("could not update attribute value"); ChangeSetTestHelpers::commit_and_update_snapshot_to_visibility(ctx) .await .expect("could not commit and update snapshot to visibility"); // the first_componenent still has 1 let input_value = get_component_input_socket_value(ctx, first_child_component.id(), "one") .await + .expect("could not get input socket value") .expect("is some"); assert_eq!(input_value, serde_json::json!("1")); // the component is updated with 4 let input_value = get_component_input_socket_value(ctx, first_child_component.id(), "three") .await + .expect("could not get input socket value") .expect("is some"); assert_eq!(input_value, serde_json::json!("4")); @@ -978,6 +1081,7 @@ async fn up_frames_moving_deeply_nested_frames(ctx: &mut DalContext) { // the parent is updated with 5 let input_value = get_component_input_socket_value(ctx, parent_frame.id(), "two") .await + .expect("could not get input socket value") .expect("is some"); assert_eq!(input_value, serde_json::json!("5")); @@ -986,26 +1090,35 @@ async fn up_frames_moving_deeply_nested_frames(ctx: &mut DalContext) { #[test] async fn simple_down_frames_nesting(ctx: &mut DalContext) { // create parent frame - let even_parent_frame = - create_component_for_schema_name(ctx, "large even lego", "even parent").await; + let even_parent_frame = create_component_for_schema_name(ctx, "large even lego", "even parent") + .await + .expect("could not create component"); - let _ = even_parent_frame + even_parent_frame .set_type(ctx, ComponentType::ConfigurationFrameDown) - .await; + .await + .expect("could not set type"); // create child frame - let even_child_frame = - create_component_for_schema_name(ctx, "medium even lego", "even child").await; + let even_child_frame = create_component_for_schema_name(ctx, "medium even lego", "even child") + .await + .expect("could not create component"); - let _ = even_child_frame + even_child_frame .set_type(ctx, ComponentType::ConfigurationFrameDown) - .await; + .await + .expect("could not set type"); // insert child frame into parent frame Frame::upsert_parent(ctx, even_child_frame.id(), even_parent_frame.id()) .await .expect("can upsert parent"); // create component - let odd_component = create_component_for_schema_name(ctx, "large odd lego", "odd").await; - let _ = odd_component.set_type(ctx, ComponentType::Component).await; + let odd_component = create_component_for_schema_name(ctx, "large odd lego", "odd") + .await + .expect("could not create component"); + odd_component + .set_type(ctx, ComponentType::Component) + .await + .expect("could not set type"); // insert component into CHILD frame Frame::upsert_parent(ctx, odd_component.id(), even_child_frame.id()) .await @@ -1016,7 +1129,8 @@ async fn simple_down_frames_nesting(ctx: &mut DalContext) { &["root", "domain", "five"], serde_json::json!["5"], ) - .await; + .await + .expect("could not update attribute value"); ChangeSetTestHelpers::commit_and_update_snapshot_to_visibility(ctx) .await @@ -1025,12 +1139,14 @@ async fn simple_down_frames_nesting(ctx: &mut DalContext) { // the output socket value is updated with 1 let output_value = get_component_output_socket_value(ctx, even_parent_frame.id(), "five") .await + .expect("could not get output socket value") .expect("is some"); assert_eq!(output_value, serde_json::json!("5")); // the component is updated with 5 let input_value = get_component_input_socket_value(ctx, odd_component.id(), "five") .await + .expect("could not get input socket value") .expect("is some"); assert_eq!(input_value, serde_json::json!("5")); @@ -1041,7 +1157,8 @@ async fn simple_down_frames_nesting(ctx: &mut DalContext) { &["root", "domain", "three"], serde_json::json!["4"], ) - .await; + .await + .expect("could not update attribute value"); ChangeSetTestHelpers::commit_and_update_snapshot_to_visibility(ctx) .await @@ -1050,6 +1167,7 @@ async fn simple_down_frames_nesting(ctx: &mut DalContext) { assert!( get_component_input_socket_value(ctx, odd_component.id(), "three") .await + .expect("could not get input socket value") .is_none() ); @@ -1060,7 +1178,8 @@ async fn simple_down_frames_nesting(ctx: &mut DalContext) { &["root", "domain", "three"], serde_json::json!["3"], ) - .await; + .await + .expect("could not update attribute value"); ChangeSetTestHelpers::commit_and_update_snapshot_to_visibility(ctx) .await @@ -1068,6 +1187,7 @@ async fn simple_down_frames_nesting(ctx: &mut DalContext) { // the component gets the update as the child frame is a closer match let input_value = get_component_input_socket_value(ctx, odd_component.id(), "three") .await + .expect("could not get input socket value") .expect("is some"); assert_eq!(input_value, serde_json::json!("3")); @@ -1091,20 +1211,29 @@ async fn simple_down_frames_nesting(ctx: &mut DalContext) { // make sure the input socket for the component is updated let input_value = get_component_input_socket_value(ctx, odd_component.id(), "three") .await + .expect("could not get input socket value") .expect("is some"); assert_eq!(input_value, serde_json::json!("4")); } #[test] async fn simple_up_frames_some_nesting(ctx: &mut DalContext) { - let even_component = create_component_for_schema_name(ctx, "small even lego", "even").await; + let even_component = create_component_for_schema_name(ctx, "small even lego", "even") + .await + .expect("could not create component"); - let _ = even_component.set_type(ctx, ComponentType::Component).await; + even_component + .set_type(ctx, ComponentType::Component) + .await + .expect("could not set type"); - let odd_up_frame = create_component_for_schema_name(ctx, "large odd lego", "odd").await; - let _ = odd_up_frame + let odd_up_frame = create_component_for_schema_name(ctx, "large odd lego", "odd") + .await + .expect("could not create component"); + odd_up_frame .set_type(ctx, ComponentType::ConfigurationFrameUp) - .await; + .await + .expect("could not set type"); Frame::upsert_parent(ctx, even_component.id(), odd_up_frame.id()) .await .expect("could not upsert parent"); @@ -1115,7 +1244,8 @@ async fn simple_up_frames_some_nesting(ctx: &mut DalContext) { &["root", "domain", "one"], serde_json::json!["1"], ) - .await; + .await + .expect("could not update attribute value"); ChangeSetTestHelpers::commit_and_update_snapshot_to_visibility(ctx) .await @@ -1123,23 +1253,28 @@ async fn simple_up_frames_some_nesting(ctx: &mut DalContext) { // the output socket value is updated with "1" let output_value = get_component_output_socket_value(ctx, even_component.id(), "one") .await + .expect("could not get output socket value") .expect("has value"); assert_eq!(output_value, serde_json::json!("1")); // make sure component output socket matches on the up frames input socket let input_value = get_component_input_socket_value(ctx, odd_up_frame.id(), "one") .await + .expect("could not get input socket value") .expect("has value"); assert_eq!(input_value, serde_json::json!("1")); //let's add another component to the frame, to drive the "3" input socket let another_even_component = - create_component_for_schema_name(ctx, "medium even lego", "another even").await; + create_component_for_schema_name(ctx, "medium even lego", "another even") + .await + .expect("could not create component"); - let _ = another_even_component + another_even_component .set_type(ctx, ComponentType::Component) - .await; + .await + .expect("could not set type"); Frame::upsert_parent(ctx, another_even_component.id(), odd_up_frame.id()) .await .expect("could not upsert parent"); @@ -1154,7 +1289,8 @@ async fn simple_up_frames_some_nesting(ctx: &mut DalContext) { &["root", "domain", "three"], serde_json::json!("3"), ) - .await; + .await + .expect("could not update attribute value"); ChangeSetTestHelpers::commit_and_update_snapshot_to_visibility(ctx) .await @@ -1162,21 +1298,25 @@ async fn simple_up_frames_some_nesting(ctx: &mut DalContext) { // the output socket value is updated with "3" let output_value = get_component_output_socket_value(ctx, another_even_component.id(), "three") .await + .expect("could not get output socket value") .expect("has value"); assert_eq!(output_value, serde_json::json!("3")); // make sure component output socket matches on the up frames input socket let input_value = get_component_input_socket_value(ctx, odd_up_frame.id(), "three") .await + .expect("could not get input socket value") .expect("has value"); assert_eq!(input_value, serde_json::json!("3")); //now let's drop that up frame into an even up frame, driving the even values - let even_up_frame = - create_component_for_schema_name(ctx, "large even lego", "another even").await; + let even_up_frame = create_component_for_schema_name(ctx, "large even lego", "another even") + .await + .expect("could not create component"); - let _ = even_up_frame + even_up_frame .set_type(ctx, ComponentType::ConfigurationFrameUp) - .await; + .await + .expect("could not set type"); Frame::upsert_parent(ctx, odd_up_frame.id(), even_up_frame.id()) .await .expect("could not upsert parent frame"); @@ -1191,7 +1331,8 @@ async fn simple_up_frames_some_nesting(ctx: &mut DalContext) { &["root", "domain", "two"], serde_json::json!("2"), ) - .await; + .await + .expect("could not update attribute value"); ChangeSetTestHelpers::commit_and_update_snapshot_to_visibility(ctx) .await @@ -1200,12 +1341,14 @@ async fn simple_up_frames_some_nesting(ctx: &mut DalContext) { // the output socket value is updated with "2" let output_value = get_component_output_socket_value(ctx, odd_up_frame.id(), "two") .await + .expect("could not get output socket value") .expect("has value"); assert_eq!(output_value, serde_json::json!("2")); // even up frame input socket matches odd up frame output socket let input_value = get_component_input_socket_value(ctx, even_up_frame.id(), "two") .await + .expect("could not get input socket value") .expect("has value"); assert_eq!(input_value, serde_json::json!("2")); } @@ -1214,12 +1357,17 @@ async fn simple_up_frames_some_nesting(ctx: &mut DalContext) { async fn up_frames_multiple_children_moves_and_deletes(ctx: &mut DalContext) { // create two components to feed an up frame let first_component = - create_component_for_schema_name(ctx, "medium even lego", "first_component").await; + create_component_for_schema_name(ctx, "medium even lego", "first_component") + .await + .expect("could not create component"); let second_component = - create_component_for_schema_name(ctx, "medium even lego", "second_component").await; - let first_up_frame = - create_component_for_schema_name(ctx, "medium odd lego", "first_frame").await; + create_component_for_schema_name(ctx, "medium even lego", "second_component") + .await + .expect("could not create component"); + let first_up_frame = create_component_for_schema_name(ctx, "medium odd lego", "first_frame") + .await + .expect("could not create component"); first_up_frame .set_type(ctx, ComponentType::ConfigurationFrameUp) .await @@ -1243,23 +1391,27 @@ async fn up_frames_multiple_children_moves_and_deletes(ctx: &mut DalContext) { &["root", "domain", "one"], serde_json::json!("1"), ) - .await; + .await + .expect("could not update attribute value"); update_attribute_value_for_component( ctx, second_component_id, &["root", "domain", "one"], serde_json::json!("2"), ) - .await; + .await + .expect("could not update attribute value"); ChangeSetTestHelpers::commit_and_update_snapshot_to_visibility(ctx) .await .expect("could not commit and update snapshot to visibility"); // make sure output socket values are updated for components let first_output = get_component_output_socket_value(ctx, first_component_id, "one") .await + .expect("could not get output socket value") .expect("has some"); let second_output = get_component_output_socket_value(ctx, second_component_id, "one") .await + .expect("could not get output socket value") .expect("has value"); assert_eq!(first_output, serde_json::json!("1")); assert_eq!(second_output, serde_json::json!("2")); @@ -1267,15 +1419,21 @@ async fn up_frames_multiple_children_moves_and_deletes(ctx: &mut DalContext) { //make sure input socket value is updated let input_value = get_component_input_socket_value(ctx, first_up_frame_id, "one") .await + .expect("could not get input socket value") .expect("has value"); assert_eq!(input_value, serde_json::json!(["1", "2"])); // create two more components in another up frame let third_component = - create_component_for_schema_name(ctx, "medium even lego", "first_component").await; + create_component_for_schema_name(ctx, "medium even lego", "first_component") + .await + .expect("could not create component"); let fourth_component = - create_component_for_schema_name(ctx, "medium even lego", "second_component").await; - let second_up_frame = - create_component_for_schema_name(ctx, "medium odd lego", "first_frame").await; + create_component_for_schema_name(ctx, "medium even lego", "second_component") + .await + .expect("could not create component"); + let second_up_frame = create_component_for_schema_name(ctx, "medium odd lego", "first_frame") + .await + .expect("could not create component"); //cache ids for later let third_component_id = third_component.id(); let fourth_component_id = fourth_component.id(); @@ -1298,23 +1456,27 @@ async fn up_frames_multiple_children_moves_and_deletes(ctx: &mut DalContext) { &["root", "domain", "one"], serde_json::json!("3"), ) - .await; + .await + .expect("could not update attribute value"); update_attribute_value_for_component( ctx, fourth_component.id(), &["root", "domain", "one"], serde_json::json!("4"), ) - .await; + .await + .expect("could not update attribute value"); ChangeSetTestHelpers::commit_and_update_snapshot_to_visibility(ctx) .await .expect("could not commit and update snapshot to visibility"); // make sure output socket values are updated for components let third_output = get_component_output_socket_value(ctx, third_component_id, "one") .await + .expect("could not get output socket value") .expect("has some"); let fourth_output = get_component_output_socket_value(ctx, fourth_component_id, "one") .await + .expect("could not get output socket value") .expect("has value"); assert_eq!(third_output, serde_json::json!("3")); assert_eq!(fourth_output, serde_json::json!("4")); @@ -1322,12 +1484,14 @@ async fn up_frames_multiple_children_moves_and_deletes(ctx: &mut DalContext) { //make sure input socket value is updated let input_value = get_component_input_socket_value(ctx, second_up_frame_id, "one") .await + .expect("could not get input socket value") .expect("has value"); assert_eq!(input_value, serde_json::json!(["3", "4"])); // both up frames feed the final up frame - let parent_up_frame = - create_component_for_schema_name(ctx, "small even lego", "parent_frame").await; + let parent_up_frame = create_component_for_schema_name(ctx, "small even lego", "parent_frame") + .await + .expect("could not create component"); let parent_up_frame_id = parent_up_frame.id(); Frame::upsert_parent(ctx, first_up_frame_id, parent_up_frame_id) .await @@ -1342,6 +1506,7 @@ async fn up_frames_multiple_children_moves_and_deletes(ctx: &mut DalContext) { assert_eq!( get_component_input_socket_value(ctx, parent_up_frame_id, "two") .await + .expect("could not get input socket value") .expect("value exists"), serde_json::json!([null, null]) ); @@ -1352,12 +1517,14 @@ async fn up_frames_multiple_children_moves_and_deletes(ctx: &mut DalContext) { &["root", "domain", "two"], serde_json::json!("5"), ) - .await; + .await + .expect("could not update attribute value"); ChangeSetTestHelpers::commit_and_update_snapshot_to_visibility(ctx) .await .expect("could not commit and update snapshot to visibility"); let input_value = get_component_input_socket_value(ctx, parent_up_frame_id, "two") .await + .expect("could not get input socket value") .expect("has value"); assert_eq!(input_value, serde_json::json!(["5", null])); //set second frame's outptu socket value and make sure both are now flowing @@ -1367,12 +1534,14 @@ async fn up_frames_multiple_children_moves_and_deletes(ctx: &mut DalContext) { &["root", "domain", "two"], serde_json::json!("6"), ) - .await; + .await + .expect("could not update attribute value"); ChangeSetTestHelpers::commit_and_update_snapshot_to_visibility(ctx) .await .expect("could not commit and update snapshot to visibility"); let input_value = get_component_input_socket_value(ctx, parent_up_frame_id, "two") .await + .expect("could not get input socket value") .expect("has value"); assert_eq!(input_value, serde_json::json!(["5", "6"])); @@ -1393,11 +1562,13 @@ async fn up_frames_multiple_children_moves_and_deletes(ctx: &mut DalContext) { // first frame should have two components let input_value = get_component_input_socket_value(ctx, first_up_frame_id, "one") .await + .expect("could not get input socket value") .expect("got value"); assert_eq!(input_value, serde_json::json!(["2", "3"])); // second frame should have one component let input_value = get_component_input_socket_value(ctx, second_up_frame_id, "one") .await + .expect("could not get input socket value") .expect("has value"); assert_eq!(input_value, serde_json::json!("4")); } diff --git a/lib/dal/tests/integration_test/frame/omega_nesting.rs b/lib/dal/tests/integration_test/frame/omega_nesting.rs index e9bac55d20..71b78f09d6 100644 --- a/lib/dal/tests/integration_test/frame/omega_nesting.rs +++ b/lib/dal/tests/integration_test/frame/omega_nesting.rs @@ -35,7 +35,8 @@ async fn down_frames_omega_nesting(ctx: &mut DalContext) { level_one_schema_name, level_one_component_name.as_str(), ) - .await; + .await + .expect("could not create component"); level_one .set_type(ctx, ComponentType::ConfigurationFrameDown) .await @@ -48,7 +49,8 @@ async fn down_frames_omega_nesting(ctx: &mut DalContext) { level_two_schema_name, level_two_component_name.as_str(), ) - .await; + .await + .expect("could not create component"); level_two .set_type(ctx, ComponentType::ConfigurationFrameDown) .await @@ -61,7 +63,8 @@ async fn down_frames_omega_nesting(ctx: &mut DalContext) { level_three_schema_name, level_three_component_name.as_str(), ) - .await; + .await + .expect("could not create component"); level_three .set_type(ctx, ComponentType::ConfigurationFrameDown) .await @@ -74,7 +77,8 @@ async fn down_frames_omega_nesting(ctx: &mut DalContext) { level_three_no_children_schema_name, level_three_no_children_component_name.as_str(), ) - .await; + .await + .expect("could not create component"); level_three_no_children .set_type(ctx, ComponentType::ConfigurationFrameDown) .await @@ -87,7 +91,8 @@ async fn down_frames_omega_nesting(ctx: &mut DalContext) { level_four_schema_name, level_four_component_name.as_str(), ) - .await; + .await + .expect("could not create component"); level_four .set_type(ctx, ComponentType::ConfigurationFrameDown) .await @@ -100,7 +105,8 @@ async fn down_frames_omega_nesting(ctx: &mut DalContext) { level_five_schema_name, level_five_component_name.as_str(), ) - .await; + .await + .expect("could not create component"); level_five .set_type(ctx, ComponentType::ConfigurationFrameDown) .await @@ -113,7 +119,8 @@ async fn down_frames_omega_nesting(ctx: &mut DalContext) { level_five_no_children_schema_name, level_five_no_children_component_name.as_str(), ) - .await; + .await + .expect("could not create component"); level_five_no_children .set_type(ctx, ComponentType::ConfigurationFrameDown) .await @@ -126,7 +133,8 @@ async fn down_frames_omega_nesting(ctx: &mut DalContext) { level_six_schema_name, level_six_component_name.as_str(), ) - .await; + .await + .expect("could not create component"); level_six .set_type(ctx, ComponentType::ConfigurationFrameDown) .await diff --git a/lib/dal/tests/integration_test/frame/with_actions.rs b/lib/dal/tests/integration_test/frame/with_actions.rs index d8e7928f8e..9ca1cbeb7b 100644 --- a/lib/dal/tests/integration_test/frame/with_actions.rs +++ b/lib/dal/tests/integration_test/frame/with_actions.rs @@ -12,12 +12,16 @@ use dal_test::helpers::{ use dal_test::{test, WorkspaceSignup}; use pretty_assertions_sorted::assert_eq; +// FIXME(nick): this test has intermittent failures and is flakey. Added the "ignore" macro for now +// and will fix it. #[test] +#[ignore] async fn delete_frame_with_child_with_resource(ctx: &mut DalContext, nw: WorkspaceSignup) { // Create the components we need and commit. let parent_component_id = { - let parent_component = - create_component_for_schema_name(ctx, "dummy-secret", "parent").await; + let parent_component = create_component_for_schema_name(ctx, "dummy-secret", "parent") + .await + .expect("could not create component"); parent_component .set_type(ctx, ComponentType::ConfigurationFrameDown) .await @@ -25,7 +29,9 @@ async fn delete_frame_with_child_with_resource(ctx: &mut DalContext, nw: Workspa parent_component.id() }; let child_component_id = { - let child_component = create_component_for_schema_name(ctx, "fallout", "child").await; + let child_component = create_component_for_schema_name(ctx, "fallout", "child") + .await + .expect("could not create component"); child_component.id() }; ChangeSetTestHelpers::commit_and_update_snapshot_to_visibility(ctx) @@ -59,7 +65,9 @@ async fn delete_frame_with_child_with_resource(ctx: &mut DalContext, nw: Workspa "the final shape", secret_definition_name.to_string(), None, - &encrypt_message(ctx, nw.key_pair.pk(), &serde_json::json![{"value": "todd"}]).await, + &encrypt_message(ctx, nw.key_pair.pk(), &serde_json::json![{"value": "todd"}]) + .await + .expect("could not encrypt message"), nw.key_pair.pk(), Default::default(), Default::default(), diff --git a/lib/dal/tests/integration_test/func/authoring/test_execute.rs b/lib/dal/tests/integration_test/func/authoring/test_execute.rs index d6eb20146f..79dfda5dbc 100644 --- a/lib/dal/tests/integration_test/func/authoring/test_execute.rs +++ b/lib/dal/tests/integration_test/func/authoring/test_execute.rs @@ -13,7 +13,9 @@ async fn test_execute_action_func(ctx: &mut DalContext) { let func_args = serde_json::Value::Null; let schema_name = "starfield"; - let component = create_component_for_schema_name(ctx, schema_name, component_name).await; + let component = create_component_for_schema_name(ctx, schema_name, component_name) + .await + .expect("could not create component"); ChangeSetTestHelpers::commit_and_update_snapshot_to_visibility(ctx) .await .expect("could not commit and update snapshot to visibility"); @@ -57,7 +59,9 @@ async fn test_execute_attribute_func(ctx: &mut DalContext) { let func_args = serde_json::Value::Array(Vec::new()); let schema_name = "starfield"; - let component = create_component_for_schema_name(ctx, schema_name, component_name).await; + let component = create_component_for_schema_name(ctx, schema_name, component_name) + .await + .expect("could not create component"); ChangeSetTestHelpers::commit_and_update_snapshot_to_visibility(ctx) .await .expect("could not commit and update snapshot to visibility"); @@ -101,7 +105,9 @@ async fn test_execute_code_generation_func(ctx: &mut DalContext) { let func_args = serde_json::value::Value::Null; let schema_name = "katy perry"; - let component = create_component_for_schema_name(ctx, schema_name, component_name).await; + let component = create_component_for_schema_name(ctx, schema_name, component_name) + .await + .expect("could not create component"); ChangeSetTestHelpers::commit_and_update_snapshot_to_visibility(ctx) .await .expect("could not commit and update snapshot to visibility"); @@ -145,7 +151,9 @@ async fn test_execute_qualification_func(ctx: &mut DalContext) { let func_args = serde_json::value::Value::Null; let schema_name = "dummy-secret"; - let component = create_component_for_schema_name(ctx, schema_name, component_name).await; + let component = create_component_for_schema_name(ctx, schema_name, component_name) + .await + .expect("could not create component"); ChangeSetTestHelpers::commit_and_update_snapshot_to_visibility(ctx) .await .expect("could not commit and update snapshot to visibility"); @@ -189,7 +197,9 @@ async fn test_execute_with_modified_code(ctx: &mut DalContext) { let func_args = serde_json::Value::Array(Vec::new()); let schema_name = "starfield"; - let component = create_component_for_schema_name(ctx, schema_name, component_name).await; + let component = create_component_for_schema_name(ctx, schema_name, component_name) + .await + .expect("could not create component"); ChangeSetTestHelpers::commit_and_update_snapshot_to_visibility(ctx) .await .expect("could not commit and update snapshot to visibility"); diff --git a/lib/dal/tests/integration_test/property_editor.rs b/lib/dal/tests/integration_test/property_editor.rs index b713af0914..1f037b2ad2 100644 --- a/lib/dal/tests/integration_test/property_editor.rs +++ b/lib/dal/tests/integration_test/property_editor.rs @@ -39,7 +39,9 @@ async fn assemble(ctx: &DalContext) { #[test] async fn array_map_manipulation(ctx: &DalContext) { - let component = create_component_for_schema_name(ctx, "pirate", "ss poopcanoe").await; + let component = create_component_for_schema_name(ctx, "pirate", "ss poopcanoe") + .await + .expect("could not create component"); let parrot_names_value_id = component .attribute_values_for_prop(ctx, &["root", "domain", "parrot_names"]) @@ -292,8 +294,9 @@ async fn array_map_manipulation(ctx: &DalContext) { #[test] async fn override_value_then_reset(ctx: &mut DalContext) { let original_pirate_name = "Thomas Cavendish"; - let pirate_component = - create_component_for_schema_name(ctx, "pirate", original_pirate_name).await; + let pirate_component = create_component_for_schema_name(ctx, "pirate", original_pirate_name) + .await + .expect("could not create component"); ChangeSetTestHelpers::commit_and_update_snapshot_to_visibility(ctx) .await .expect("could not commit and update snapshot to visibility"); @@ -325,7 +328,9 @@ async fn override_value_then_reset(ctx: &mut DalContext) { }], // expected PropEditorTestView::for_component_id(ctx, pirate_component.id()) .await + .expect("could not get property editor test view") .get_value(name_path) + .expect("could not get value") ); // if we set a value directly on domain/name, overridden becomes true @@ -352,7 +357,9 @@ async fn override_value_then_reset(ctx: &mut DalContext) { }], // expected PropEditorTestView::for_component_id(ctx, pirate_component.id()) .await + .expect("could not get property editor test view") .get_value(name_path) + .expect("could not get value") ); AttributeValue::use_default_prototype(ctx, av_id) @@ -377,15 +384,18 @@ async fn override_value_then_reset(ctx: &mut DalContext) { }], // expected PropEditorTestView::for_component_id(ctx, pirate_component.id()) .await + .expect("could not get property editor test view") .get_value(name_path) + .expect("could not get value") ); } #[test] async fn override_array_then_reset(ctx: &mut DalContext) { let original_pirate_name = "Thomas Cavendish"; - let pirate_component = - create_component_for_schema_name(ctx, "pirate", original_pirate_name).await; + let pirate_component = create_component_for_schema_name(ctx, "pirate", original_pirate_name) + .await + .expect("could not create component"); ChangeSetTestHelpers::commit_and_update_snapshot_to_visibility(ctx) .await .expect("could not commit and update snapshot to visibility"); @@ -417,7 +427,9 @@ async fn override_array_then_reset(ctx: &mut DalContext) { }], // expected PropEditorTestView::for_component_id(ctx, pirate_component.id()) .await + .expect("could not get property editor test view") .get_value(name_path) + .expect("could not get value") ); AttributeValue::update(ctx, av_id, Some(serde_json::json!([]))) @@ -442,7 +454,9 @@ async fn override_array_then_reset(ctx: &mut DalContext) { }], // expected PropEditorTestView::for_component_id(ctx, pirate_component.id()) .await + .expect("could not get property editor test view") .get_value(name_path) + .expect("could not get value") ); AttributeValue::use_default_prototype(ctx, av_id) @@ -467,14 +481,18 @@ async fn override_array_then_reset(ctx: &mut DalContext) { }], // expected PropEditorTestView::for_component_id(ctx, pirate_component.id()) .await + .expect("could not get property editor test view") .get_value(name_path) + .expect("could not get value") ); } #[test] async fn prop_can_be_set_by_socket(ctx: &mut DalContext) { let pirate_name = "Blackbeard"; - let pirate_component = create_component_for_schema_name(ctx, "pirate", pirate_name).await; + let pirate_component = create_component_for_schema_name(ctx, "pirate", pirate_name) + .await + .expect("could not create component"); let parrots_path = &["root", "domain", "parrot_names"]; @@ -505,10 +523,14 @@ async fn prop_can_be_set_by_socket(ctx: &mut DalContext) { }], // expected PropEditorTestView::for_component_id(ctx, pirate_component.id()) .await + .expect("could not get property editor test view") .get_value(parrots_path) + .expect("could not get value") ); - let pet_shop_component = create_component_for_schema_name(ctx, "pet_shop", "Petopia").await; + let pet_shop_component = create_component_for_schema_name(ctx, "pet_shop", "Petopia") + .await + .expect("could not create component"); connect_components_with_socket_names( ctx, @@ -517,7 +539,8 @@ async fn prop_can_be_set_by_socket(ctx: &mut DalContext) { pirate_component.id(), "parrot_names", ) - .await; + .await + .expect("could not connect components with socket names"); ChangeSetTestHelpers::commit_and_update_snapshot_to_visibility(ctx) .await @@ -538,7 +561,9 @@ async fn prop_can_be_set_by_socket(ctx: &mut DalContext) { }], // expected PropEditorTestView::for_component_id(ctx, pirate_component.id()) .await + .expect("could not get property editor test view") .get_value(parrots_path) + .expect("could not get value") ); } @@ -546,7 +571,9 @@ async fn prop_can_be_set_by_socket(ctx: &mut DalContext) { async fn values_controlled_by_ancestor(ctx: &mut DalContext) { let pirate_name = "Long John Silver"; let parrot_name = "Captain Flint"; - let pirate_component = create_component_for_schema_name(ctx, "pirate", pirate_name).await; + let pirate_component = create_component_for_schema_name(ctx, "pirate", pirate_name) + .await + .expect("could not create component"); let parrots_path = &["root", "domain", "parrot_names"]; let parrot_entry_path = &["root", "domain", "parrot_names", "parrot_name"]; @@ -577,10 +604,14 @@ async fn values_controlled_by_ancestor(ctx: &mut DalContext) { }], // expected PropEditorTestView::for_component_id(ctx, pirate_component.id()) .await + .expect("could not get property editor test view") .get_value(parrots_path) + .expect("could not get value") ); - let pet_shop_component = create_component_for_schema_name(ctx, "pet_shop", "Petopia").await; + let pet_shop_component = create_component_for_schema_name(ctx, "pet_shop", "Petopia") + .await + .expect("could not create component"); // set value on source component { @@ -603,7 +634,8 @@ async fn values_controlled_by_ancestor(ctx: &mut DalContext) { pirate_component.id(), "parrot_names", ) - .await; + .await + .expect("could not connect components with socket names"); ChangeSetTestHelpers::commit_and_update_snapshot_to_visibility(ctx) .await @@ -625,7 +657,9 @@ async fn values_controlled_by_ancestor(ctx: &mut DalContext) { }], // expected PropEditorTestView::for_component_id(ctx, pirate_component.id()) .await + .expect("could not get property editor test view") .get_value(parrots_path) + .expect("could not get value") ); // av for entry is controlled by ancestor @@ -658,7 +692,9 @@ async fn values_controlled_by_ancestor(ctx: &mut DalContext) { }], // expected PropEditorTestView::for_component_id(ctx, pirate_component.id()) .await + .expect("could not get property editor test view") .get_value(&["root", "domain", "parrot_names", "0"]) + .expect("could not get value") ); } } diff --git a/lib/dal/tests/integration_test/qualifications.rs b/lib/dal/tests/integration_test/qualifications.rs index 349a4b8cec..58d9399513 100644 --- a/lib/dal/tests/integration_test/qualifications.rs +++ b/lib/dal/tests/integration_test/qualifications.rs @@ -16,7 +16,8 @@ async fn list_qualifications(ctx: &mut DalContext) { "dummy-secret", "deserializing serde json value null into an option results in None and that's insane", ) - .await; + .await + .expect("could not create component"); // Prepare expected qualification views. let expected_prop_validations_qualification_view = QualificationView { diff --git a/lib/dal/tests/integration_test/rebaser.rs b/lib/dal/tests/integration_test/rebaser.rs index 6d1bc3a943..519e5d576e 100644 --- a/lib/dal/tests/integration_test/rebaser.rs +++ b/lib/dal/tests/integration_test/rebaser.rs @@ -1,13 +1,10 @@ use base64::{engine::general_purpose, Engine}; use dal::func::argument::{FuncArgument, FuncArgumentKind}; -use dal::workspace_snapshot::conflict::Conflict; use dal::{ AttributeValue, ChangeSet, Component, DalContext, Func, FuncBackendKind, - FuncBackendResponseType, TransactionsError, -}; -use dal_test::helpers::{ - create_component_for_schema_name, ChangeSetTestHelpers, ChangeSetTestHelpersError, + FuncBackendResponseType, }; +use dal_test::helpers::{create_component_for_schema_name, ChangeSetTestHelpers}; use dal_test::test; use pretty_assertions_sorted::assert_eq; @@ -294,24 +291,30 @@ async fn func_node_with_arguments_conflict(ctx: &mut DalContext) { .expect("able to list args"); assert_eq!(1, args.len()); - let result = ChangeSetTestHelpers::apply_change_set_to_base(ctx).await; - assert!(matches!( - result, - Err(ChangeSetTestHelpersError::ChangeSetApply(_)) - )); - - if let Err(ChangeSetTestHelpersError::Transactions(TransactionsError::ConflictsOccurred( - conflicts, - ))) = result - { - assert_eq!(1, conflicts.conflicts_found.len()); - let conflict = conflicts - .conflicts_found - .first() - .expect("conflict should be there") - .to_owned(); - assert!(matches!(conflict, Conflict::ExclusiveEdgeMismatch { .. })); - } + // NOTE(nick): at the time of writing, this test has the "#![ignore]" macro applied and we've + // removed the formal "ChangeSetTestHelpersError" enum in favor of the "eyre!" and "Result" + // type. As an aside, that change was made to help make error reporting more clear for runtime + // assertion failures and explicit "expect" and "panic" usages in tests. Anyway, how the + // conflicts are detected will likely be slightly different in the future, so commenting this + // out for now should suffice. Please don't hesitate to reach out with questions or rage. + // let result = ChangeSetTestHelpers::apply_change_set_to_base(ctx).await; + // assert!(matches!( + // result, + // Err(ChangeSetTestHelpersError::ChangeSetApply(_)) + // )); + // + // if let Err(ChangeSetTestHelpersError::Transactions(TransactionsError::ConflictsOccurred( + // conflicts, + // ))) = result + // { + // assert_eq!(1, conflicts.conflicts_found.len()); + // let conflict = conflicts + // .conflicts_found + // .first() + // .expect("conflict should be there") + // .to_owned(); + // assert!(matches!(conflict, Conflict::ExclusiveEdgeMismatch { .. })); + // } } #[test] @@ -368,6 +371,7 @@ async fn correctly_detect_unrelated_unmodified_data(ctx: &mut DalContext) { let shared_component_id = create_component_for_schema_name(ctx, "Docker Image", "Shared component") .await + .expect("could not create component") .id(); ChangeSetTestHelpers::commit_and_update_snapshot_to_visibility(ctx) .await @@ -419,6 +423,7 @@ async fn correctly_detect_unrelated_unmodified_data(ctx: &mut DalContext) { let _change_set_b_component_id = create_component_for_schema_name(ctx, "Docker Image", "Change Set B Component") .await + .expect("could not creat component") .id(); ChangeSetTestHelpers::commit_and_update_snapshot_to_visibility(ctx) .await diff --git a/lib/dal/tests/integration_test/schema/variant.rs b/lib/dal/tests/integration_test/schema/variant.rs index e4649b29e8..afb111b1e9 100644 --- a/lib/dal/tests/integration_test/schema/variant.rs +++ b/lib/dal/tests/integration_test/schema/variant.rs @@ -11,7 +11,7 @@ mod view; #[test] async fn new(ctx: &DalContext) { - let schema = create_schema(ctx).await; + let schema = create_schema(ctx).await.expect("could not create schema"); let (variant, _) = SchemaVariant::new( ctx, @@ -33,7 +33,7 @@ async fn new(ctx: &DalContext) { #[test] async fn find_code_item_prop(ctx: &DalContext) { - let schema = create_schema(ctx).await; + let schema = create_schema(ctx).await.expect("could not create schema"); let (schema_variant, root_prop) = SchemaVariant::new( ctx, schema.id(), @@ -66,7 +66,7 @@ async fn find_code_item_prop(ctx: &DalContext) { #[test] async fn list_root_si_child_props(ctx: &DalContext) { - let schema = create_schema(ctx).await; + let schema = create_schema(ctx).await.expect("could not create schema"); let (schema_variant, root_prop) = SchemaVariant::new( ctx, schema.id(), diff --git a/lib/dal/tests/integration_test/schema/variant/authoring/update_variant.rs b/lib/dal/tests/integration_test/schema/variant/authoring/update_variant.rs index ba4b06783f..411f0aa3d6 100644 --- a/lib/dal/tests/integration_test/schema/variant/authoring/update_variant.rs +++ b/lib/dal/tests/integration_test/schema/variant/authoring/update_variant.rs @@ -61,7 +61,9 @@ async fn update_variant(ctx: &mut DalContext) { assert_eq!(my_first_variant.id(), updated_sv_id); // Add a component to the diagram - create_component_for_schema_name(ctx, my_asset_schema.name.clone(), "demo component").await; + create_component_for_schema_name(ctx, my_asset_schema.name.clone(), "demo component") + .await + .expect("could not create component"); let diagram = Diagram::assemble(ctx) .await .expect("could not assemble diagram"); @@ -100,7 +102,9 @@ async fn update_variant(ctx: &mut DalContext) { assert_ne!(second_updated_sv_id, my_first_variant.id()); // Let's ensure that our latest prop is visible in the component - create_component_for_schema_name(ctx, my_asset_schema.name.clone(), "demo component 2").await; + create_component_for_schema_name(ctx, my_asset_schema.name.clone(), "demo component 2") + .await + .expect("could not create component"); let diagram = Diagram::assemble(ctx) .await .expect("could not assemble diagram"); diff --git a/lib/dal/tests/integration_test/secret.rs b/lib/dal/tests/integration_test/secret.rs index 9f661ba54d..23f66142e4 100644 --- a/lib/dal/tests/integration_test/secret.rs +++ b/lib/dal/tests/integration_test/secret.rs @@ -16,7 +16,7 @@ mod with_actions; #[test] async fn new(ctx: &DalContext, nw: &WorkspaceSignup) { - let name = generate_fake_name(); + let name = generate_fake_name().expect("could not generate fake name"); // Ensure that secret creation works. let secret = Secret::new( @@ -56,7 +56,7 @@ async fn new(ctx: &DalContext, nw: &WorkspaceSignup) { #[test] async fn encrypt_decrypt_round_trip(ctx: &DalContext, nw: &WorkspaceSignup) { let pkey = nw.key_pair.public_key(); - let name = generate_fake_name(); + let name = generate_fake_name().expect("could not generate fake name"); // Create an encrypted message. let message = serde_json::json!({"song": "Bar Round Here"}); @@ -109,7 +109,7 @@ async fn update_metadata_and_encrypted_contents(ctx: &DalContext, nw: &Workspace let key_pair_pk = nw.key_pair.pk(); let version = SecretVersion::default(); let algorithm = SecretAlgorithm::default(); - let name = generate_fake_name(); + let name = generate_fake_name().expect("could not generate fake name"); // Create a message to encrypt and use for the secret. let message = serde_json::json!({"song": "Smile", "artist": "midwxst"}); @@ -264,8 +264,9 @@ async fn update_encrypted_contents_with_dependent_values( nw: &WorkspaceSignup, ) { // Create a component and commit. - let component = - create_component_for_schema_name(ctx, "dummy-secret", "secret-definition").await; + let component = create_component_for_schema_name(ctx, "dummy-secret", "secret-definition") + .await + .expect("could not create component"); let schema_variant_id = Component::schema_variant_id(ctx, component.id()) .await .expect("could not get schema variant id for component"); @@ -291,10 +292,11 @@ async fn update_encrypted_contents_with_dependent_values( nw.key_pair.pk(), &serde_json::json![{"value": "howard"}], ) - .await; + .await + .expect("could not encrypt message"); let secret = Secret::new( ctx, - generate_fake_name(), + generate_fake_name().expect("could not generate fake name"), secret_definition_name, None, &encrypted_message_that_will_fail_the_qualification, @@ -338,7 +340,9 @@ async fn update_encrypted_contents_with_dependent_values( // Update the encrypted contents. let encrypted_message_that_will_pass_the_qualification = - encrypt_message(ctx, nw.key_pair.pk(), &serde_json::json![{"value": "todd"}]).await; + encrypt_message(ctx, nw.key_pair.pk(), &serde_json::json![{"value": "todd"}]) + .await + .expect("could not encrypt message"); let updated_secret = secret .update_encrypted_contents( ctx, @@ -435,7 +439,9 @@ async fn secret_definition_works_with_dummy_qualification( ) { // Create a component and commit. let secret_definition_component = - create_component_for_schema_name(ctx, "dummy-secret", "secret-definition").await; + create_component_for_schema_name(ctx, "dummy-secret", "secret-definition") + .await + .expect("could not create component"); let secret_definition_component_id = secret_definition_component.id(); ChangeSetTestHelpers::commit_and_update_snapshot_to_visibility(ctx) .await @@ -472,7 +478,8 @@ async fn secret_definition_works_with_dummy_qualification( nw.key_pair.pk(), &serde_json::json![{"value": "howard"}], ) - .await; + .await + .expect("could not encrypt message"); let secret_that_will_fail_the_qualification = Secret::new( ctx, "secret that will fail the qualification", @@ -553,7 +560,9 @@ async fn secret_definition_works_with_dummy_qualification( { // Create a secret with a value that will pass the qualification and commit. let encrypted_message_that_will_pass_the_qualification = - encrypt_message(ctx, nw.key_pair.pk(), &serde_json::json![{"value": "todd"}]).await; + encrypt_message(ctx, nw.key_pair.pk(), &serde_json::json![{"value": "todd"}]) + .await + .expect("could not encrypt message"); let secret_that_will_pass_the_qualification = Secret::new( ctx, "secret that will pass the qualification", diff --git a/lib/dal/tests/integration_test/secret/with_actions.rs b/lib/dal/tests/integration_test/secret/with_actions.rs index 7ae230bc42..4a76afe994 100644 --- a/lib/dal/tests/integration_test/secret/with_actions.rs +++ b/lib/dal/tests/integration_test/secret/with_actions.rs @@ -12,12 +12,15 @@ use pretty_assertions_sorted::assert_eq; #[test] async fn create_action_using_secret(ctx: &mut DalContext, nw: &WorkspaceSignup) { // Create the components we need and commit. - let source_component = create_component_for_schema_name(ctx, "dummy-secret", "source").await; + let source_component = create_component_for_schema_name(ctx, "dummy-secret", "source") + .await + .expect("could not create component"); let source_schema_variant_id = Component::schema_variant_id(ctx, source_component.id()) .await .expect("could not get schema variant id for component"); - let destination_component = - create_component_for_schema_name(ctx, "fallout", "destination").await; + let destination_component = create_component_for_schema_name(ctx, "fallout", "destination") + .await + .expect("could not create component"); let destination_schema_variant_id = Component::schema_variant_id(ctx, destination_component.id()) .await @@ -66,7 +69,9 @@ async fn create_action_using_secret(ctx: &mut DalContext, nw: &WorkspaceSignup) "johnqt", secret_definition_name.to_string(), None, - &encrypt_message(ctx, nw.key_pair.pk(), &serde_json::json![{"value": "todd"}]).await, + &encrypt_message(ctx, nw.key_pair.pk(), &serde_json::json![{"value": "todd"}]) + .await + .expect("could not encrypt message"), nw.key_pair.pk(), Default::default(), Default::default(), diff --git a/lib/dal/tests/integration_test/validations.rs b/lib/dal/tests/integration_test/validations.rs index 13443f0ced..7577f4c51c 100644 --- a/lib/dal/tests/integration_test/validations.rs +++ b/lib/dal/tests/integration_test/validations.rs @@ -10,7 +10,9 @@ use serde_json::json; #[test] async fn validation_format_errors(ctx: &mut DalContext) { - let component = create_component_for_schema_name(ctx, "BadValidations", "bad").await; + let component = create_component_for_schema_name(ctx, "BadValidations", "bad") + .await + .expect("could not create component"); ChangeSetTestHelpers::commit_and_update_snapshot_to_visibility(ctx) .await .expect("could not commit and update snapshot to visibility"); @@ -18,7 +20,9 @@ async fn validation_format_errors(ctx: &mut DalContext) { let bad_json_path = &["root", "domain", "bad_validation_json"]; let prop_view = PropEditorTestView::for_component_id(ctx, component.id()) .await - .get_value(bad_json_path); + .expect("could not get property editor test view") + .get_value(bad_json_path) + .expect("could not get value"); assert_eq!( json!({ "value": null, @@ -33,7 +37,9 @@ async fn validation_format_errors(ctx: &mut DalContext) { let bad_format_path = &["root", "domain", "bad_validation_format"]; let prop_view = PropEditorTestView::for_component_id(ctx, component.id()) .await - .get_value(bad_format_path); + .expect("could not get property editor test view") + .get_value(bad_format_path) + .expect("could not get value"); assert_eq!( json!({ @@ -49,7 +55,9 @@ async fn validation_format_errors(ctx: &mut DalContext) { #[test] async fn prop_editor_validation(ctx: &mut DalContext) { - let component = create_component_for_schema_name(ctx, "pirate", "Robinson Crusoe").await; + let component = create_component_for_schema_name(ctx, "pirate", "Robinson Crusoe") + .await + .expect("could not create component"); ChangeSetTestHelpers::commit_and_update_snapshot_to_visibility(ctx) .await .expect("could not commit and update snapshot to visibility"); @@ -64,7 +72,9 @@ async fn prop_editor_validation(ctx: &mut DalContext) { let prop_view = PropEditorTestView::for_component_id(ctx, component.id()) .await - .get_value(prop_path); + .expect("could not get property editor test view") + .get_value(prop_path) + .expect("could not get value"); assert_eq!( json!({ @@ -87,7 +97,9 @@ async fn prop_editor_validation(ctx: &mut DalContext) { let prop_view = PropEditorTestView::for_component_id(ctx, component.id()) .await - .get_value(prop_path); + .expect("could not get property editor test view") + .get_value(prop_path) + .expect("could not get value"); assert_eq!( json!({ @@ -110,7 +122,9 @@ async fn prop_editor_validation(ctx: &mut DalContext) { let prop_view = PropEditorTestView::for_component_id(ctx, component.id()) .await - .get_value(prop_path); + .expect("could not get property editor test view") + .get_value(prop_path) + .expect("could not get value"); assert_eq!( json!({ @@ -126,8 +140,12 @@ async fn prop_editor_validation(ctx: &mut DalContext) { #[test] async fn validation_on_dependent_value(ctx: &mut DalContext) { - let output_component = create_component_for_schema_name(ctx, "ValidatedOutput", "Output").await; - let input_component = create_component_for_schema_name(ctx, "ValidatedInput", "Input").await; + let output_component = create_component_for_schema_name(ctx, "ValidatedOutput", "Output") + .await + .expect("could not create component"); + let input_component = create_component_for_schema_name(ctx, "ValidatedInput", "Input") + .await + .expect("could not create component"); ChangeSetTestHelpers::commit_and_update_snapshot_to_visibility(ctx) .await @@ -140,7 +158,8 @@ async fn validation_on_dependent_value(ctx: &mut DalContext) { input_component.id(), "number", ) - .await; + .await + .expect("could not connect components with socket names"); let prop_path = &["root", "domain", "a_number"]; let av_id = output_component @@ -160,10 +179,14 @@ async fn validation_on_dependent_value(ctx: &mut DalContext) { let source_prop_view = PropEditorTestView::for_component_id(ctx, output_component.id()) .await - .get_value(prop_path); + .expect("could not get property test view") + .get_value(prop_path) + .expect("could not get value"); let destination_prop_view = PropEditorTestView::for_component_id(ctx, input_component.id()) .await - .get_value(prop_path); + .expect("could not get property test view") + .get_value(prop_path) + .expect("could not get value"); // Check validations and values let source_result = extract_value_and_validation(source_prop_view); @@ -192,10 +215,14 @@ async fn validation_on_dependent_value(ctx: &mut DalContext) { let source_prop_view = PropEditorTestView::for_component_id(ctx, input_component.id()) .await - .get_value(prop_path); + .expect("could not get property test view") + .get_value(prop_path) + .expect("could not get value"); let destination_prop_view = PropEditorTestView::for_component_id(ctx, output_component.id()) .await - .get_value(prop_path); + .expect("could not get property test view") + .get_value(prop_path) + .expect("could not get value"); let source_result = extract_value_and_validation(source_prop_view); assert_eq!( @@ -216,7 +243,9 @@ async fn validation_on_dependent_value(ctx: &mut DalContext) { #[test] async fn multiple_changes_single_validation(ctx: &mut DalContext) { - let component = create_component_for_schema_name(ctx, "pirate", "Robinson Crusoe").await; + let component = create_component_for_schema_name(ctx, "pirate", "Robinson Crusoe") + .await + .expect("could not create component"); let prop_path = &["root", "domain", "working_eyes"]; let av_id = component @@ -272,7 +301,9 @@ async fn multiple_changes_single_validation(ctx: &mut DalContext) { #[test] async fn validation_qualification(ctx: &mut DalContext) { - let component = create_component_for_schema_name(ctx, "pirate", "Robinson Crusoe").await; + let component = create_component_for_schema_name(ctx, "pirate", "Robinson Crusoe") + .await + .expect("could not create component"); ChangeSetTestHelpers::commit_and_update_snapshot_to_visibility(ctx) .await diff --git a/lib/dal/tests/integration_test/workspace.rs b/lib/dal/tests/integration_test/workspace.rs index 4e38436b3e..42f80b1f44 100644 --- a/lib/dal/tests/integration_test/workspace.rs +++ b/lib/dal/tests/integration_test/workspace.rs @@ -22,7 +22,9 @@ async fn export_import_loop(ctx: &mut DalContext) { // Create Component With Value let original_pirate_name = "Cap'n Crunch "; - create_component_for_schema_name(ctx, "pirate", original_pirate_name).await; + create_component_for_schema_name(ctx, "pirate", original_pirate_name) + .await + .expect("could not create component"); ChangeSetTestHelpers::commit_and_update_snapshot_to_visibility(ctx) .await .expect("commit and update snapshot to visibility"); @@ -99,7 +101,9 @@ async fn export_import_loop(ctx: &mut DalContext) { original_pirate_name, // expected PropEditorTestView::for_component_id(ctx, component.id) //actual .await + .expect("could not get property editor test view") .get_value(name_path) + .expect("could not get value") .get("value") .expect("get value for domain/name") );