-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix indent in yaml not producing results
- Loading branch information
1 parent
4af9ebf
commit 6c52cf8
Showing
6 changed files
with
55 additions
and
37 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,19 @@ | ||
pub struct OutputWriter {} | ||
impl OutputWriter { | ||
pub fn prologue() -> String{ | ||
pub fn prologue() -> String { | ||
"digraph D {\n".to_string() | ||
} | ||
|
||
pub fn epilogue() -> String{ | ||
pub fn epilogue() -> String { | ||
"}\n".to_string() | ||
} | ||
|
||
pub fn write_output(job_name: &String, job_parent: &String, hex_color: &String) -> String { | ||
let mut result = format!(" {} -> {}\n", job_name, job_parent); | ||
result += &format!(" \"{}\" [style=filled, fillcolor=\"{}\"]\n", job_name, hex_color); | ||
let mut result = format!(" \"{}\" -> \"{}\"\n", job_name, job_parent); | ||
result += &format!( | ||
" \"{}\" [style=filled, fillcolor=\"{}\"]\n", | ||
job_name, hex_color | ||
); | ||
result | ||
} | ||
} |
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 |
---|---|---|
@@ -1,28 +1,36 @@ | ||
#[cfg(test)] | ||
mod tests { | ||
use regex::Regex; | ||
use crate::dot_generator::DotGenerator; | ||
use regex::Regex; | ||
|
||
#[test] | ||
fn test_when_typical() { | ||
let dot_generator = DotGenerator {}; | ||
let args = ["zuulgraph","/home/mihai/git/zuulgraph/test/yaml/demo_file1.yaml","/home/mihai/git/zuulgraph/test/yaml/demo_file2.yaml"].iter().map(|&s| s.into()).collect(); | ||
let expected = concat!("digraph D {\n", | ||
" JobB_file1 -> A_file2\n", | ||
" \"JobB_file1\" [style=filled, fillcolor=\"\"]\n", | ||
" JobC_file1 -> JobB_file1\n", | ||
" \"JobC_file1\" [style=filled, fillcolor=\"\"]\n", | ||
" JobD_file1 -> JobB_file1\n", | ||
" \"JobD_file1\" [style=filled, fillcolor=\"\"]\n", | ||
" A_file2 -> JobA_file1\n", | ||
" \"A_file2\" [style=filled, fillcolor=\"\"]\n", | ||
"}\n"); | ||
let args = [ | ||
"zuulgraph", | ||
"/home/mihai/git/zuulgraph/test/yaml/demo_file1.yaml", | ||
"/home/mihai/git/zuulgraph/test/yaml/demo_file2.yaml", | ||
] | ||
.iter() | ||
.map(|&s| s.into()) | ||
.collect(); | ||
let expected = concat!( | ||
"digraph D {\n", | ||
" JobB_file1 -> A_file2\n", | ||
" \"JobB_file1\" [style=filled, fillcolor=\"\"]\n", | ||
" JobC_file1 -> JobB_file1\n", | ||
" \"JobC_file1\" [style=filled, fillcolor=\"\"]\n", | ||
" JobD_file1 -> JobB_file1\n", | ||
" \"JobD_file1\" [style=filled, fillcolor=\"\"]\n", | ||
" A_file2 -> JobA_file1\n", | ||
" \"A_file2\" [style=filled, fillcolor=\"\"]\n", | ||
"}\n" | ||
); | ||
|
||
let result = dot_generator.run(args); | ||
let re = Regex::new(r"#[A-Z0-9]+").unwrap(); | ||
let postprocessed_result = re.replace_all(result.as_str(), ""); | ||
|
||
assert_eq!(postprocessed_result, expected); | ||
|
||
assert_eq!(postprocessed_result, expected); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,14 +1,14 @@ | ||
- job: | ||
name: JobA_file1 | ||
name: JobA_file1 | ||
|
||
- job: | ||
name: JobB_file1 | ||
parent: A_file2 | ||
name: JobB_file1 | ||
parent: A_file2 | ||
|
||
- job: | ||
name: JobC_file1 | ||
parent: JobB_file1 | ||
name: JobC_file1 | ||
parent: JobB_file1 | ||
|
||
- job: | ||
name: JobD_file1 | ||
parent: JobB_file1 | ||
name: JobD_file1 | ||
parent: JobB_file1 |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
- job: | ||
name: A_file2 | ||
parent: JobA_file1 | ||
name: A_file2 | ||
parent: JobA_file1 |