Repository: comtrya/comtrya (language: rust)

Issue:
Fix: Move application integration tests to app crate so they actually run
## I'm submitting a

- [X] bug fix
- [ ] feature
- [ ] documentation addition

## What is the current behaviour?

Integration tests don't run

## What is the expected behavior?

Integration tests should run


Turns out that the dev dependency removal in #324 was *slightly* erroneous. Integration tests weren't in the proper directory so were never actually running or picked up as integration tests. This made `cargo-udeps` give a false positive for them.

This wasn't that big of a deal, considering the one integration test *intended* to test whether help printed but never actually did that.

Also moves `utils.rs` to a folder module, since they aren't picked up by the integration test scanner. the `run` command was changed to not strip out the initial "comtrya" since I found this a confusing behavior until I checked the implementation.



Discussion / hints:

Fix patch:
diff --git a/app/src/commands/apply.rs b/app/src/commands/apply.rs
index 00bf5115..634b1724 100644
--- a/app/src/commands/apply.rs
+++ b/app/src/commands/apply.rs
@@ -16,6 +16,9 @@ pub(crate) struct Apply {
     /// Performs a dry-run without changing the system
     #[structopt(long)]
     dry_run: bool,
+
+    #[structopt(short = "l", long = "label")]
+    pub label: Option<String>,
 }
 
 #[instrument(skip(args, runtime))]
@@ -47,6 +50,7 @@ pub(crate) fn execute(args: &Apply, runtime: &Runtime) -> anyhow::Result<()> {
         name: None,
         depends: vec![],
         actions: vec![],
+        ..Default::default()
     };
 
     let root_index = dag.add_node(manifest_root);
@@ -129,6 +133,18 @@ pub(crate) fn execute(args: &Apply, runtime: &Runtime) -> anyhow::Result<()> {
 
             let mut successful = true;
 
+            if args.label.is_some() {
+                let label = args.label.clone().unwrap();
+
+                if !m1.labels.contains(&label) {
+                    info!(
+                        message = "Skipping manifest, label not found",
+                        label = label.as_str()
+                    );
+                    continue;
+                }
+            }
+
             if let Some(where_condition) = &m1.r#where {
                 let where_result = match engine.eval_with_scope::<bool>(&mut scope, where_condition)
                 {
diff --git a/examples/labels/label.yaml b/examples/labels/label.yaml
new file mode 100644
index 00000000..8e138423
--- /dev/null
+++ b/examples/labels/label.yaml
@@ -0,0 +1,8 @@
+labels:
+  - labelled
+
+actions:
+  - action: command.run
+    command: echo
+    args:
+      - "Hello"
diff --git a/lib/src/actions/file/link.rs b/lib/src/actions/file/link.rs
index 1a3ab5bd..7e8f08dc 100644
--- a/lib/src/actions/file/link.rs
+++ b/lib/src/actions/file/link.rs
@@ -191,6 +191,7 @@ mod tests {
             depends: vec![],
             name: None,
             dag_index: None,
+            ..Default::default()
         };
 
         let config = Config::default();
@@ -246,6 +247,7 @@ mod tests {
             depends: vec![],
             name: None,
             dag_index: None,
+            ..Default::default()
         };
 
         let config = Config::default();
diff --git a/lib/src/manifests/mod.rs b/lib/src/manifests/mod.rs
index 04dc0a7d..6f310893 100644
--- a/lib/src/manifests/mod.rs
+++ b/lib/src/manifests/mod.rs
@@ -10,7 +10,7 @@ use serde::{Deserialize, Serialize};
 use std::path::{Path, PathBuf};
 use tracing::error;
 
-#[derive(JsonSchema, Clone, Debug, Serialize, Deserialize)]
+#[derive(JsonSchema, Clone, Debug, Default, Serialize, Deserialize)]
 pub struct Manifest {
     #[serde(default)]
     pub r#where: Option<String>,
@@ -18,6 +18,9 @@ pub struct Manifest {
     #[serde(default)]
     pub name: Option<String>,
 
+    #[serde(default)]
+    pub labels: Vec<String>,
+
     #[serde(default)]
     pub depends: Vec<String>,
 


Test patch: