diff --git a/bookmarks/dbbookmarks/src/lib.rs b/bookmarks/dbbookmarks/src/lib.rs index 934144c94c..d72ec7e918 100644 --- a/bookmarks/dbbookmarks/src/lib.rs +++ b/bookmarks/dbbookmarks/src/lib.rs @@ -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(), } } diff --git a/bookmarks/dbbookmarks/tests/main.rs b/bookmarks/dbbookmarks/tests/main.rs index cf28a453bd..c989be4712 100644 --- a/bookmarks/dbbookmarks/tests/main.rs +++ b/bookmarks/dbbookmarks/tests/main.rs @@ -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); diff --git a/bookmarks/src/lib.rs b/bookmarks/src/lib.rs index 8ed7c8dc21..6eb48c7a7d 100644 --- a/bookmarks/src/lib.rs +++ b/bookmarks/src/lib.rs @@ -518,6 +518,9 @@ impl ConvIr 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)), } }