Skip to content

Commit

Permalink
test: add test for jenkinsfile integration
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Feb 26, 2021
1 parent 413dace commit 0995ee6
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions plugins/coco_container/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ edition = "2018"

[dependencies]
dockerfile-parser = "0.7.1"
jenkinsfile = "0.1.1"

[dependencies.core_model]
path = "../../core_model"
Expand Down
24 changes: 24 additions & 0 deletions plugins/coco_container/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ pub fn plugin() -> Box<dyn PluginInterface> {
#[cfg(test)]
mod tests {
use dockerfile_parser::Dockerfile;
use jenkinsfile::Jenkinsfile;

#[test]
pub fn demo() {
Expand All @@ -52,4 +53,27 @@ mod tests {
}
}
}

#[test]
pub fn should_parse_hello_world() {
let code = r#"pipeline {
agent { docker 'maven:3.3.3' }
stages {
stage('build') {
steps {
sh 'mvn --version'
}
}
}
}
"#;
let jenkinsfile = Jenkinsfile::from_str(code).unwrap();

for stage in jenkinsfile.stages {
println!("stage # {}", stage.name);
for ins in stage.steps {
println!("steps # {}", ins);
}
}
}
}

0 comments on commit 0995ee6

Please sign in to comment.