mononoke: fix new backsyncer update reason

Summary:
Do a few fixes for the new "backsyncer" update reason.

I also added a few checks to make sure we don't run into this problems again.

Reviewed By: ikostia

Differential Revision: D18395398

fbshipit-source-id: d61839d54fe1c8f9c2a4c858762c040db32daf4d
This commit is contained in:
Stanislau Hlebik 2019-11-08 06:33:20 -08:00 committed by Facebook Github Bot
parent b363deb4f0
commit cb7570678b
3 changed files with 62 additions and 1 deletions

View File

@ -770,6 +770,9 @@ impl SqlBookmarksTransaction {
}
| TestMove {
bundle_replay_data: Some(bundle_replay_data),
}
| Backsyncer {
bundle_replay_data: Some(bundle_replay_data),
} => {
let BundleReplayData {
bundle_handle,
@ -784,7 +787,20 @@ impl SqlBookmarksTransaction {
.map(move |(sql_transaction, _)| sql_transaction)
.boxify()
}
_ => future::ok(sql_transaction).boxify(),
Pushrebase {
bundle_replay_data: None,
}
| Push {
bundle_replay_data: None,
}
| TestMove {
bundle_replay_data: None,
}
| Backsyncer {
bundle_replay_data: None,
}
| ManualMove
| Blobimport => future::ok(sql_transaction).boxify(),
}
}

View File

@ -16,6 +16,7 @@ use bookmarks::{
};
use context::CoreContext;
use dbbookmarks::{SqlBookmarks, SqlConstructors};
use failure_ext::Error;
use fbinit::FacebookInit;
use futures::{Future, Stream};
use maplit::hashmap;
@ -25,6 +26,7 @@ use mononoke_types_mocks::changesetid::{
FIVES_CSID, FOURS_CSID, ONES_CSID, SIXES_CSID, THREES_CSID, TWOS_CSID,
};
use mononoke_types_mocks::repo::{REPO_ONE, REPO_TWO, REPO_ZERO};
use sql::mysql_async::{prelude::ConvIr, Value};
use std::collections::HashMap;
fn create_bookmark_name(book: &str) -> BookmarkName {
@ -1237,6 +1239,46 @@ fn test_read_log_entry_many_repos(fb: FacebookInit) {
);
}
#[fbinit::test]
fn test_update_reason_conversion(_fb: FacebookInit) -> Result<(), Error> {
let unusedreason = BookmarkUpdateReason::TestMove {
bundle_replay_data: None,
};
use BookmarkUpdateReason::*;
match unusedreason {
Backsyncer { .. } => {}
Blobimport => {}
ManualMove => {}
Push { .. } => {}
Pushrebase { .. } => {}
TestMove { .. } => {} // PLEASE ADD A TEST FOR A NEW BOOKMARK UPDATE REASON
};
let reasons = vec![
Backsyncer {
bundle_replay_data: None,
},
Blobimport,
ManualMove,
Push {
bundle_replay_data: None,
},
Pushrebase {
bundle_replay_data: None,
},
TestMove {
bundle_replay_data: None,
},
];
for reason in reasons {
let value = Value::from(reason);
BookmarkUpdateReason::new(value)?;
}
Ok(())
}
#[fbinit::test]
fn test_list_bookmark_log_entries(fb: FacebookInit) {
let ctx = CoreContext::test_mock(fb);

View File

@ -518,6 +518,9 @@ impl ConvIr<BookmarkUpdateReason> for BookmarkUpdateReason {
Value::Bytes(ref b) if b == &b"testmove" => Ok(BookmarkUpdateReason::TestMove {
bundle_replay_data: None,
}),
Value::Bytes(ref b) if b == &b"backsyncer" => Ok(BookmarkUpdateReason::Backsyncer {
bundle_replay_data: None,
}),
v => Err(FromValueError(v)),
}
}