Skip to content

Commit

Permalink
Merge pull request #9 from openSUSE/e2e-test
Browse files Browse the repository at this point in the history
End to end testing using assert_cmd
  • Loading branch information
dottorblaster authored Dec 26, 2024
2 parents 7dbded0 + 15a86e8 commit 687a26f
Show file tree
Hide file tree
Showing 14 changed files with 203 additions and 5 deletions.
180 changes: 180 additions & 0 deletions Cargo.lock

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

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@ anyhow = "1.0.95"
flate2 = "1.0.35"
tar = "0.4.43"
zstd = "0.13.2"

[dev-dependencies]
assert_cmd = "2.0.16"
predicates = "3.1.3"
6 changes: 3 additions & 3 deletions src/mix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ mod tests {

#[test]
fn fetch_mix_deps_successful() {
let result = fetch_mix_deps("test/test_project");
fs::remove_dir_all("test/test_project/deps").unwrap();
let result = fetch_mix_deps("tests/test_project");
fs::remove_dir_all("tests/test_project/deps").unwrap();
assert!(result.is_ok());
}

#[test]
fn fetch_mix_deps_error() {
let result = fetch_mix_deps("test/carbonara");
let result = fetch_mix_deps("tests/carbonara");
assert!(result.is_err());
}
}
4 changes: 2 additions & 2 deletions src/tarballs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ mod tests {

#[test]
fn recompress_successful() {
let result = recompress("vendor.tar.gz", "test/test_compression", "gz");
let result = recompress("vendor.tar.gz", "tests/test_compression", "gz");
fs::remove_file("vendor.tar.gz").unwrap();
assert!(result.is_ok());
}

#[test]
fn recompress_error() {
let result = recompress("vendor2.tar.gz", "test/carbonara", "gz");
let result = recompress("vendor2.tar.gz", "tests/carbonara", "gz");
fs::remove_file("vendor2.tar.gz").unwrap();
assert!(result.is_err());
}
Expand Down
14 changes: 14 additions & 0 deletions tests/cli.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
use assert_cmd::prelude::*;
use predicates::prelude::*;
use std::process::Command;

#[test]
fn prints_help() -> Result<(), Box<dyn std::error::Error>> {
let mut cmd = Command::cargo_bin("obs-service-elixir_mix_deps")?;

cmd.assert()
.failure()
.stderr(predicate::str::contains("Usage"));

Ok(())
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 687a26f

Please sign in to comment.