radicle: add test for removing review fields
Add a test case showing that when a review is made with a None value to an already set field, it will remove the original value. Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com> X-Clacks-Overhead: GNU Terry Pratchett
This commit is contained in:
parent
0381aa3281
commit
256471fa5e
|
|
@ -652,8 +652,14 @@ impl CodeComment {
|
||||||
#[derive(Debug, Default, Clone, PartialEq, Eq)]
|
#[derive(Debug, Default, Clone, PartialEq, Eq)]
|
||||||
pub struct Review {
|
pub struct Review {
|
||||||
/// Review verdict.
|
/// Review verdict.
|
||||||
|
///
|
||||||
|
/// Nb. if the verdict is set and a subsequent review is made with
|
||||||
|
/// the verdict as `None`, the original verdict will be nullified.
|
||||||
verdict: LWWReg<Option<Verdict>>,
|
verdict: LWWReg<Option<Verdict>>,
|
||||||
/// Review general comment.
|
/// Review general comment.
|
||||||
|
///
|
||||||
|
/// Nb. if the comment is set and a subsequent review is made with
|
||||||
|
/// the comment as `None`, the original comment will be nullified.
|
||||||
comment: LWWReg<Option<Max<String>>>,
|
comment: LWWReg<Option<Max<String>>>,
|
||||||
/// Review inline code comments.
|
/// Review inline code comments.
|
||||||
inline: LWWSet<Max<CodeComment>>,
|
inline: LWWSet<Max<CodeComment>>,
|
||||||
|
|
@ -1671,6 +1677,48 @@ mod test {
|
||||||
assert_eq!(review.comment(), Some("LGTM"));
|
assert_eq!(review.comment(), Some("LGTM"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_patch_review_remove_fields() {
|
||||||
|
let tmp = tempfile::tempdir().unwrap();
|
||||||
|
let (_, signer, project) = test::setup::context(&tmp);
|
||||||
|
let base = git::Oid::from_str("cb18e95ada2bb38aadd8e6cef0963ce37a87add3").unwrap();
|
||||||
|
let oid = git::Oid::from_str("518d5069f94c03427f694bb494ac1cd7d1339380").unwrap();
|
||||||
|
let mut patches = Patches::open(&project).unwrap();
|
||||||
|
let mut patch = patches
|
||||||
|
.create(
|
||||||
|
"My first patch",
|
||||||
|
"Blah blah blah.",
|
||||||
|
MergeTarget::Delegates,
|
||||||
|
base,
|
||||||
|
oid,
|
||||||
|
&[],
|
||||||
|
&signer,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let (rid, _) = patch.latest().unwrap();
|
||||||
|
let rid = *rid;
|
||||||
|
|
||||||
|
patch
|
||||||
|
.review(
|
||||||
|
rid,
|
||||||
|
Some(Verdict::Reject),
|
||||||
|
Some("Nah".to_owned()),
|
||||||
|
vec![],
|
||||||
|
&signer,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
patch.review(rid, None, None, vec![], &signer).unwrap();
|
||||||
|
|
||||||
|
let id = patch.id;
|
||||||
|
let patch = patches.get_mut(&id).unwrap();
|
||||||
|
let (_, revision) = patch.latest().unwrap();
|
||||||
|
|
||||||
|
let review = revision.reviews.get(signer.public_key()).unwrap();
|
||||||
|
assert_eq!(review.verdict(), None);
|
||||||
|
assert_eq!(review.comment(), None);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_patch_update() {
|
fn test_patch_update() {
|
||||||
let tmp = tempfile::tempdir().unwrap();
|
let tmp = tempfile::tempdir().unwrap();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue