B:BD[
3.2344] → [
2.1386:1468]
fn read_secret(&self, _prompt: impl Display) -> Option<String> {
None
/// User interface that records method calls and returns canned inputs
#[cfg(test)]
#[derive(Default)]
struct FakeUi {
inputs: Vec<String>,
events: Vec<FUIEvent>,
}
#[cfg(test)]
enum FUIEvent {
//TODO figure out how to solve lifetime issues
// and store Media in this variant
// Or just convert it to a string? idk
Show,
Warn(String),
Read(String),
ReadSecret(String),
}
#[cfg(test)]
impl FakeUi {
pub fn new() -> Self {
Default::default()
}
}
#[cfg(test)]
impl Ui for FakeUi {
fn show(&mut self, _content: media::Media) {
self.events.push(FUIEvent::Show)
}
fn warn<D: Display>(&mut self, warning: D) {
self.events.push(FUIEvent::Warn(warning.to_string()))
}
fn read(&mut self, prompt: impl Display) -> Option<String> {
self.events.push(FUIEvent::Read(prompt.to_string()));
self.inputs.pop()
}
fn read_secret(&mut self, prompt: impl Display) -> Option<String> {
self.events.push(FUIEvent::ReadSecret(prompt.to_string()));
self.inputs.pop()