[][src]Function dishub::ops::start_daemon::verify

pub fn verify(
    config_dir: &(String, PathBuf)
) -> Result<(PathBuf, PathBuf), Error>

Verify if, given the current configuration, it's permitted to continue with the subsequent steps of the start_daemon subsystem.

The return value contains either the path to the file containing the global app tokens and the path to the file containing the global feeds or why getting them failed.

Examples

Verifying an existing tokens and feeds file.

let tf = temp_dir().join("dishub-doctest").join("ops-start_daemon-verify-0");
fs::create_dir_all(&tf).unwrap();
File::create(tf.join("tokens.toml")).unwrap().write(&[]).unwrap();
File::create(tf.join("feeds.toml")).unwrap().write(&[]).unwrap();

assert_eq!(start_daemon::verify(&("$TEMP/ops-start_daemon-verify-0".to_string(), tf.clone())),
           Ok((tf.join("tokens.toml"), tf.join("feeds.toml"))));

Verifying a nonexistant tokens file.

let tf = temp_dir().join("dishub-doctest").join("ops-start_daemon-verify-1");
assert_eq!(start_daemon::verify(&("$TEMP/ops-start_daemon-verify-1".to_string(), tf)),
           Err(Error::RequiredFileFromSubsystemNonexistant {
                   subsys: "init",
                   fname: "$TEMP/ops-start_daemon-verify-1/tokens.toml".to_string(),
               }));

Verifying a nonexistant feeds file.

let tf = temp_dir().join("dishub-doctest").join("ops-start_daemon-verify-2");
fs::create_dir_all(&tf).unwrap();
File::create(tf.join("tokens.toml")).unwrap().write(&[]).unwrap();

let tf = temp_dir().join("dishub-doctest").join("ops-start_daemon-verify-2");
assert_eq!(start_daemon::verify(&("$TEMP/ops-start_daemon-verify-2".to_string(), tf)),
           Err(Error::RequiredFileFromSubsystemNonexistant {
                   subsys: "add-feeds",
                   fname: "$TEMP/ops-start_daemon-verify-2/feeds.toml".to_string(),
               }));