mixnode: Add tests for upgrade to 10.0.2
Add a positive and a negative unit test for upgrading to 10.0.2. Signed-off-by: Bogdan-Ștefan Neacșu <bogdan@nymtech.net>
This commit is contained in:
Generated
+23
@@ -1830,6 +1830,7 @@ dependencies = [
|
||||
"rocket",
|
||||
"rocket_contrib",
|
||||
"serde",
|
||||
"serial_test",
|
||||
"tokio",
|
||||
"tokio-util",
|
||||
"toml",
|
||||
@@ -2839,6 +2840,28 @@ dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serial_test"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e0bccbcf40c8938196944a3da0e133e031a33f4d6b72db3bda3cc556e361905d"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"parking_lot",
|
||||
"serial_test_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serial_test_derive"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b2acd6defeddb41eb60bb468f8825d0cfd0c2a76bc03bfd235b6a1dc4f6a1ad5"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sha-1"
|
||||
version = "0.8.2"
|
||||
|
||||
@@ -38,3 +38,6 @@ pemstore = { path = "../common/pemstore" }
|
||||
topology = { path = "../common/topology" }
|
||||
validator-client = { path = "../common/client-libs/validator-client" }
|
||||
version-checker = { path = "../common/version-checker" }
|
||||
|
||||
[dev-dependencies]
|
||||
serial_test = "0.5"
|
||||
|
||||
@@ -447,3 +447,39 @@ pub fn execute(matches: &ArgMatches) {
|
||||
// here be upgrade path to 0.9.X and beyond based on version number from config
|
||||
do_upgrade(existing_config, matches, package_version)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod upgrade_tests {
|
||||
use super::*;
|
||||
use serial_test::serial;
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn test_patch_0_10_2_upgrade() {
|
||||
let config = Config::default().with_id("0").with_custom_version("0.10.1");
|
||||
let matches = ArgMatches::default();
|
||||
let old_version = Version::new(0, 10, 1);
|
||||
let new_version = Version::new(0, 10, 2);
|
||||
let new_config =
|
||||
patch_0_10_2_upgrade(config, &matches, &old_version, &new_version).unwrap();
|
||||
assert_eq!(new_config.get_version(), "0.10.2");
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn test_patch_0_10_2_upgrade_error() {
|
||||
let config = Config::default().with_id("0").with_custom_version("0.10.1");
|
||||
let matches = ArgMatches::default();
|
||||
let old_version = Version::new(0, 10, 1);
|
||||
let new_version = Version::new(0, 10, 2);
|
||||
config.save_to_file(None).unwrap();
|
||||
let config_file = config.get_config_file_save_location();
|
||||
let initial_perms = fs::metadata(config_file.clone()).unwrap().permissions();
|
||||
let mut new_perms = initial_perms.clone();
|
||||
new_perms.set_readonly(true);
|
||||
fs::set_permissions(config_file.clone(), new_perms).unwrap();
|
||||
let ret = patch_0_10_2_upgrade(config, &matches, &old_version, &new_version);
|
||||
fs::set_permissions(config_file, initial_perms).unwrap();
|
||||
assert!(ret.is_err());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user