[][src]Function dishub::ops::add_feeds::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 add_feeds 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.

The app tokens are required, but if the feeds file doesn't exist and empty one will be created.

Examples

Verifying an existing tokens file.

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

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

Verifying a nonexistant tokens file.

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