-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove outfile option for generate-scheme subcommand for simplicity (#75
- Loading branch information
1 parent
d43450c
commit f00f1fa
Showing
8 changed files
with
211 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,196 @@ | ||
mod utils; | ||
|
||
use std::fs; | ||
|
||
use crate::utils::setup; | ||
use anyhow::Result; | ||
use utils::CUSTOM_SCHEMES_DIR_NAME; | ||
|
||
#[test] | ||
fn test_cli_generatescheme_subcommand_custom_properties() -> Result<()> { | ||
// --- | ||
// Act | ||
// --- | ||
let system = "base24"; | ||
let author = "Some Author (https://github.com/tinted-theming)"; | ||
let name = "Some custom name"; | ||
let slug = "some-custom-slug"; | ||
let variant = "light"; | ||
let (_, _, command_vec, cleanup) = setup( | ||
"test_cli_generatescheme_subcommand_custom_properties", | ||
format!( | ||
"generate-scheme --author \"{}\" --name \"{}\" --slug {} --system {} --variant {} ./tests/fixtures/assets/article-featured-image.webp", | ||
author, | ||
name, | ||
slug, | ||
system, | ||
variant, | ||
) | ||
.as_str(), | ||
)?; | ||
let expected_output = format!( | ||
r#"author: "{author}" | ||
name: "{name}" | ||
slug: "{slug}" | ||
system: "{system}" | ||
variant: "{variant}" | ||
palette: | ||
base00: "f7f7f7" | ||
base01: "d5d9d6" | ||
base02: "b3bbb6" | ||
base03: "919d95" | ||
base04: "707f75" | ||
base05: "4e6154" | ||
base06: "2c4334" | ||
base07: "0b2614" | ||
base08: "dd5319" | ||
base09: "e29c0d" | ||
base0A: "e29c0d" | ||
base0B: "079f31" | ||
base0C: "00fffe" | ||
base0D: "055de1" | ||
base0E: "66495d" | ||
base0F: "97421d" | ||
base10: "ab674a" | ||
base11: "ab8943" | ||
base12: "ab8943" | ||
base13: "2d7842" | ||
base14: "41bdbd" | ||
base15: "3d68a8" | ||
base16: "5e505a" | ||
base17: "774e3c" | ||
"# | ||
); | ||
|
||
// --- | ||
// Act | ||
// --- | ||
let (stdout, stderr) = utils::run_command(command_vec).unwrap(); | ||
|
||
// ------ | ||
// Assert | ||
// ------ | ||
assert_eq!(stdout, expected_output); | ||
assert!( | ||
stderr.is_empty(), | ||
"stdout does not contain the expected output" | ||
); | ||
|
||
cleanup()?; | ||
Ok(()) | ||
} | ||
|
||
#[test] | ||
fn test_cli_generatescheme_subcommand_with_image() -> Result<()> { | ||
// --- | ||
// Act | ||
// --- | ||
let (_, _, command_vec, cleanup) = setup( | ||
"test_cli_generatescheme_subcommand_with_image", | ||
"generate-scheme --system base16 ./tests/fixtures/assets/article-featured-image.webp", | ||
)?; | ||
let expected_output = r#"author: "Tinty" | ||
name: "Tinty Generated" | ||
slug: "tinty-generated" | ||
system: "base16" | ||
variant: "dark" | ||
palette: | ||
base00: "0e2d19" | ||
base01: "2f4938" | ||
base02: "506658" | ||
base03: "718378" | ||
base04: "93a097" | ||
base05: "b4bdb7" | ||
base06: "d5dad7" | ||
base07: "f7f7f7" | ||
base08: "dd5319" | ||
base09: "e29c0d" | ||
base0A: "e29c0d" | ||
base0B: "079f31" | ||
base0C: "00fffe" | ||
base0D: "055de1" | ||
base0E: "66495d" | ||
base0F: "97421d" | ||
"#; | ||
|
||
// --- | ||
// Act | ||
// --- | ||
let (stdout, stderr) = utils::run_command(command_vec).unwrap(); | ||
|
||
// ------ | ||
// Assert | ||
// ------ | ||
assert_eq!(stdout, expected_output); | ||
assert!( | ||
stderr.is_empty(), | ||
"stdout does not contain the expected output" | ||
); | ||
|
||
cleanup()?; | ||
Ok(()) | ||
} | ||
|
||
#[test] | ||
fn test_cli_generatescheme_subcommand_with_save() -> Result<()> { | ||
// --- | ||
// Act | ||
// --- | ||
let scheme_system = "base16"; | ||
let scheme_slug = "test-scheme-slug"; | ||
let (_, data_path, command_vec, cleanup) = setup( | ||
"test_cli_generatescheme_subcommand_with_save", | ||
format!("generate-scheme --slug {scheme_slug} --system {scheme_system} --save ./tests/fixtures/assets/article-featured-image.webp").as_str(), | ||
)?; | ||
let out_scheme_path = data_path.join(format!( | ||
"{CUSTOM_SCHEMES_DIR_NAME}/{scheme_system}/{scheme_slug}.yaml" | ||
)); | ||
let expected_output = format!( | ||
r#"system: {scheme_system} | ||
name: Tinty Generated | ||
slug: {scheme_slug} | ||
author: Tinty | ||
description: null | ||
variant: dark | ||
palette: | ||
base00: 0e2d19 | ||
base01: 2f4938 | ||
base02: '506658' | ||
base03: '718378' | ||
base04: 93a097 | ||
base05: b4bdb7 | ||
base06: d5dad7 | ||
base07: f7f7f7 | ||
base08: dd5319 | ||
base09: e29c0d | ||
base0A: e29c0d | ||
base0B: 079f31 | ||
base0C: 00fffe | ||
base0D: 055de1 | ||
base0E: 66495d | ||
base0F: 97421d | ||
"# | ||
); | ||
|
||
// --- | ||
// Act | ||
// --- | ||
let (stdout, stderr) = utils::run_command(command_vec).unwrap(); | ||
let actual_output = fs::read_to_string(&out_scheme_path)?; | ||
|
||
// ------ | ||
// Assert | ||
// ------ | ||
assert_eq!(actual_output, expected_output); | ||
assert_eq!( | ||
stdout, | ||
format!("Scheme created: {}\n", out_scheme_path.display()) | ||
); | ||
assert!( | ||
stderr.is_empty(), | ||
"stdout does not contain the expected output" | ||
); | ||
|
||
cleanup()?; | ||
Ok(()) | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters