Skip to content

Commit

Permalink
fix: error when .github directory doesn't exist (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
meskill authored Nov 28, 2024
1 parent 11be623 commit 2b6eb3e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 34 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions src/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ impl Generate {
.join("workflows")
.join(self.name.as_str());

let path = path.canonicalize()?;

let content = format!("{}\n{}", comment, self.workflow.to_string()?);

let result = self.check_file(&path, &content);
Expand Down
59 changes: 28 additions & 31 deletions tests/test-workflow.rs
Original file line number Diff line number Diff line change
@@ -1,38 +1,35 @@
#[cfg(test)]
mod test {
use gh_workflow::Workflow;
use pretty_assertions::assert_eq;
use serde_json::Value;
use gh_workflow::Workflow;
use pretty_assertions::assert_eq;
use serde_json::Value;

fn split(content: &str) -> (Value, Value) {
let parsed = Workflow::parse(content).unwrap();
let actual = serde_yaml::from_str::<Value>(&parsed.to_string().unwrap()).unwrap();
let expected = serde_yaml::from_str::<Value>(content).unwrap();
fn split(content: &str) -> (Value, Value) {
let parsed = Workflow::parse(content).unwrap();
let actual = serde_yaml::from_str::<Value>(&parsed.to_string().unwrap()).unwrap();
let expected = serde_yaml::from_str::<Value>(content).unwrap();

(actual, expected)
}
(actual, expected)
}

#[test]
fn test_workflow_bench() {
let (actual, expected) = split(include_str!("./fixtures/workflow-bench.yml"));
assert_eq!(actual, expected);
}
#[test]
fn test_workflow_bench() {
let (actual, expected) = split(include_str!("./fixtures/workflow-bench.yml"));
assert_eq!(actual, expected);
}

#[test]
fn test_workflow_ci() {
let (actual, expected) = split(include_str!("./fixtures/workflow-ci.yml"));
assert_eq!(actual, expected);
}
#[test]
fn test_workflow_ci() {
let (actual, expected) = split(include_str!("./fixtures/workflow-ci.yml"));
assert_eq!(actual, expected);
}

#[test]
fn test_workflow_demo() {
let (actual, expected) = split(include_str!("./fixtures/workflow-demo.yml"));
assert_eq!(actual, expected);
}
#[test]
fn test_workflow_demo() {
let (actual, expected) = split(include_str!("./fixtures/workflow-demo.yml"));
assert_eq!(actual, expected);
}

#[test]
fn test_workflow_rust() {
let (actual, expected) = split(include_str!("./fixtures/workflow-rust.yml"));
assert_eq!(actual, expected);
}
#[test]
fn test_workflow_rust() {
let (actual, expected) = split(include_str!("./fixtures/workflow-rust.yml"));
assert_eq!(actual, expected);
}

0 comments on commit 2b6eb3e

Please sign in to comment.