feat: edit body for commit messages
This commit is contained in:
+24
-1
@@ -8,7 +8,7 @@
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use crate::{
|
||||
commit::types::{BreakingChange, CommitType, Description, Scope},
|
||||
commit::types::{Body, BreakingChange, CommitType, Description, Scope},
|
||||
error::Error,
|
||||
prompts::prompter::Prompter,
|
||||
};
|
||||
@@ -20,6 +20,7 @@ enum MockResponse {
|
||||
Scope(Scope),
|
||||
Description(Description),
|
||||
BreakingChange(BreakingChange),
|
||||
Body(Body),
|
||||
Confirm(bool),
|
||||
Error(Error),
|
||||
}
|
||||
@@ -80,6 +81,15 @@ impl MockPrompts {
|
||||
self
|
||||
}
|
||||
|
||||
/// Configure the mock to return a specific body response
|
||||
pub fn with_body(self, body: Body) -> Self {
|
||||
self.responses
|
||||
.lock()
|
||||
.unwrap()
|
||||
.push(MockResponse::Body(body));
|
||||
self
|
||||
}
|
||||
|
||||
/// Configure the mock to return a specific confirmation response
|
||||
pub fn with_confirm(self, confirm: bool) -> Self {
|
||||
self.responses
|
||||
@@ -197,6 +207,19 @@ impl Prompter for MockPrompts {
|
||||
}
|
||||
}
|
||||
|
||||
fn input_body(&self) -> Result<Body, Error> {
|
||||
self.prompts_called
|
||||
.lock()
|
||||
.unwrap()
|
||||
.push("input_body".to_string());
|
||||
|
||||
match self.responses.lock().unwrap().remove(0) {
|
||||
MockResponse::Body(body) => Ok(body),
|
||||
MockResponse::Error(e) => Err(e),
|
||||
_ => panic!("MockPrompts: Expected Body response, got different type"),
|
||||
}
|
||||
}
|
||||
|
||||
fn confirm_apply(&self, _message: &str) -> Result<bool, Error> {
|
||||
self.prompts_called
|
||||
.lock()
|
||||
|
||||
Reference in New Issue
Block a user