Skip to content

Commit

Permalink
Fix CLI tests
Browse files Browse the repository at this point in the history
  • Loading branch information
duckysmacky committed Aug 21, 2024
1 parent 710d5c5 commit 048f16d
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 17 deletions.
Binary file removed test-files/test/image.png
Binary file not shown.
1 change: 0 additions & 1 deletion test-files/test/word.txt

This file was deleted.

15 changes: 0 additions & 15 deletions test-files/test/words.txt

This file was deleted.

13 changes: 13 additions & 0 deletions tests/cli_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ fn decrypt_command(path: &PathBuf) -> Output {
.expect("Failed to execute the \"unbox\" command")
}

fn create_profile_command() -> Output {
Command::new("lockbox")
.args(&["-v", "-p", PASSWORD, "profile", "create", "test"])
.output()
.expect("Failed to execute the \"profile create\" command")
}

fn format_output(text: &str, output: Output) -> String {
format!("{}\nSTDOUT: {:?}\nSTDERR: {:?}\nSTATUS CODE: {}\n", text, output.stdout, output.stderr, output.status)
}
Expand All @@ -31,6 +38,9 @@ fn test_word_encryption() {
let test_file = Path::new(TEST_DIR).join(file_name);
let original_file = Path::new(ORIGINAL_DIR).join(file_name);

let output = create_profile_command();
assert!(output.status.success(), "{}", format_output("Profile creation failed", output));

let output = encrypt_command(&test_file);
assert!(output.status.success(), "{}", format_output("Encryption failed", output));

Expand All @@ -52,6 +62,9 @@ fn test_words_encryption() {
let test_file = Path::new(TEST_DIR).join(file_name);
let original_file = Path::new(ORIGINAL_DIR).join(file_name);

let output = create_profile_command();
assert!(output.status.success(), "{}", format_output("Profile creation failed", output));

let output = encrypt_command(&test_file);
assert!(output.status.success(), "{}", format_output("Encryption failed", output));

Expand Down
2 changes: 1 addition & 1 deletion tests/common/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::{env, fs};
use std::path::{Path, PathBuf};

pub const PASSWORD: &str = "test123"; // just a password for testing
pub const PASSWORD: &str = "test_password"; // just a password for testing
#[allow(dead_code)]
pub const ORIGINAL_DIR: &str = "test-files/original";
#[allow(dead_code)]
Expand Down

0 comments on commit 048f16d

Please sign in to comment.