-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable mocking specific parts of code
Signed-off-by: Patrik Stas <patrik.stas@absa.africa>
- Loading branch information
1 parent
291ffbf
commit 976e26d
Showing
8 changed files
with
89 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use std::collections::HashMap; | ||
use std::sync::RwLock; | ||
|
||
pub static MOCKED_GENERATED_PROOF: &str = "mocked_proof"; | ||
pub static MOCKED_RETRIEVED_CREDS: &str = "mocked_retrieved_creds"; | ||
|
||
lazy_static! { | ||
static ref MOCK_SETTINGS: RwLock<HashMap<String, String>> = RwLock::new(HashMap::new()); | ||
} | ||
|
||
pub fn set_mock_generate_indy_proof(generated_proof: &str) { | ||
let mut settings = MOCK_SETTINGS.write().unwrap(); | ||
settings.insert(String::from(MOCKED_GENERATED_PROOF), generated_proof.into()); | ||
} | ||
|
||
pub fn get_mock_generate_indy_proof() -> Option<String> { | ||
let config = MOCK_SETTINGS.read().unwrap(); | ||
config.get(MOCKED_GENERATED_PROOF).map(|s| String::from(s)) | ||
} | ||
|
||
pub fn set_mock_creds_retrieved_for_proof_request(retrieve_creds: &str) { | ||
let mut settings = MOCK_SETTINGS.write().unwrap(); | ||
settings.insert(String::from(MOCKED_RETRIEVED_CREDS), retrieve_creds.into()); | ||
} | ||
|
||
pub fn get_mock_creds_retrieved_for_proof_request() -> Option<String> { | ||
let config = MOCK_SETTINGS.read().unwrap(); | ||
config.get(MOCKED_RETRIEVED_CREDS).map(|s| String::from(s)) | ||
} | ||
|
||
pub fn reset_mock_settings() { | ||
let mut config = MOCK_SETTINGS.write().unwrap(); | ||
config.clear(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters