Skip to content

Commit

Permalink
TDD time
Browse files Browse the repository at this point in the history
  • Loading branch information
morgante committed Jan 3, 2025
1 parent 721eaa9 commit 78b877c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
2 changes: 1 addition & 1 deletion crates/cli/src/workflows.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::updater::{SupportedApp, Updater};
use anyhow::Result;
use console::style;
use log::{debug, info};
use log::debug;
use marzano_auth::env::{get_grit_api_url, ENV_VAR_GRIT_API_URL, ENV_VAR_GRIT_AUTH_TOKEN};
use marzano_auth::info::AuthInfo;
use marzano_gritmodule::config::REPO_CONFIG_DIR_NAME;
Expand Down
33 changes: 32 additions & 1 deletion crates/cli_bin/tests/workflows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,14 @@ fn applies_user_workflows() -> Result<()> {
}

#[test]
fn run_workflow_args() -> Result<()> {
fn run_workflow_input() -> Result<()> {
let (_temp_dir, temp_fixtures_root) = get_fixture("grit_modules", true)?;

let mut cmd = get_test_cmd()?;
cmd.arg("apply")
.arg("https://storage.googleapis.com/grit-workflows-dev-workflow_definitions/test/hello.js")
.arg("--input")
.arg("{\"query\": \"John\"}")
.current_dir(temp_fixtures_root);

let output = cmd.output()?;
Expand All @@ -154,5 +156,34 @@ fn run_workflow_args() -> Result<()> {
let stdout = String::from_utf8(output.stdout)?;
assert!(stdout.contains("Running hello workflow"),);

assert!(stdout.contains("John as the query"));

Ok(())
}

#[test]
fn run_workflow_arg_input() -> Result<()> {
let (_temp_dir, temp_fixtures_root) = get_fixture("grit_modules", true)?;

let mut cmd = get_test_cmd()?;
cmd.arg("apply")
.arg("https://storage.googleapis.com/grit-workflows-dev-workflow_definitions/test/hello.js")
.arg("--query=John")
.current_dir(temp_fixtures_root);

let output = cmd.output()?;
println!("stdout: {:?}", String::from_utf8(output.stdout.clone())?);
println!("stderr: {:?}", String::from_utf8(output.stderr.clone())?);

assert!(
output.status.success(),
"Command didn't finish successfully"
);

let stdout = String::from_utf8(output.stdout)?;
assert!(stdout.contains("Running hello workflow"),);

assert!(stdout.contains("John as the query"));

Ok(())
}

0 comments on commit 78b877c

Please sign in to comment.