diff --git a/tests/common/mod.rs b/tests/common/mod.rs new file mode 100644 index 0000000..2906035 --- /dev/null +++ b/tests/common/mod.rs @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: MIT-0 +// +// Fixtures shared by the integration-test crates (tests/*.rs). The unit +// tests inside src/ cannot reach this module and keep their own copies. + +// Each test crate compiles its own copy of this module and not every crate +// uses every fixture, so the dead-code lint misfires here. +#![allow(dead_code)] + +use fcry::SecretBytes32; + +/// The raw 32-byte key used by all integration tests. +pub const KEY: &[u8; 32] = b"0123456789abcdef0123456789abcdef"; + +/// [`KEY`] wrapped in the `SecretBytes32` the library API takes. +pub fn test_key() -> SecretBytes32 { + let mut key = SecretBytes32::zeroed(); + key.with_mut_array(|key| key.copy_from_slice(KEY)); + key +} diff --git a/tests/library_api.rs b/tests/library_api.rs index 2e0fbde..d09ab13 100644 --- a/tests/library_api.rs +++ b/tests/library_api.rs @@ -6,7 +6,6 @@ use fcry::{ EncryptOptions, KdfParams, OutputOptions, - SecretBytes32, decrypt, decrypt_range, default_argon_decrypt_cap_mib, @@ -14,11 +13,8 @@ use fcry::{ }; use tempfile::TempDir; -fn test_key() -> SecretBytes32 { - let mut key = SecretBytes32::zeroed(); - key.with_mut_array(|key| key.copy_from_slice(b"0123456789abcdef0123456789abcdef")); - key -} +mod common; +use common::test_key; #[test] fn library_file_roundtrip_raw_key() { diff --git a/tests/roundtrip.rs b/tests/roundtrip.rs index d87c3f3..5fc9217 100644 --- a/tests/roundtrip.rs +++ b/tests/roundtrip.rs @@ -15,7 +15,8 @@ use std::{ use assert_cmd::cargo::CommandCargoExt; use tempfile::TempDir; -const KEY: &[u8; 32] = b"0123456789abcdef0123456789abcdef"; +mod common; +use common::KEY; fn fcry() -> Command { Command::cargo_bin("fcry").unwrap()