fn test_deconstruct()

in sdk/keyvault/azure_security_keyvault_secrets/src/resource.rs [192:249]


    fn test_deconstruct() {
        deconstruct(&"file:///tmp".parse().unwrap()).expect_err("cannot-be-base url");
        deconstruct(&"https://vault.azure.net/".parse().unwrap()).expect_err("missing collection");
        deconstruct(&"https://vault.azure.net/collection/".parse().unwrap())
            .expect_err("invalid collection");
        deconstruct(&"https://vault.azure.net/secrets/".parse().unwrap())
            .expect_err("missing name");

        let url: Url = "https://vault.azure.net/secrets/name".parse().unwrap();
        assert_eq!(
            deconstruct(&url).unwrap(),
            ResourceId {
                source_id: url.to_string(),
                vault_url: "https://vault.azure.net".into(),
                name: "name".into(),
                version: None
            }
        );

        let url: Url = "https://vault.azure.net/secrets/name/version"
            .parse()
            .unwrap();
        assert_eq!(
            deconstruct(&url).unwrap(),
            ResourceId {
                source_id: url.to_string(),
                vault_url: "https://vault.azure.net".into(),
                name: "name".into(),
                version: Some("version".into()),
            }
        );

        let url: Url = "https://vault.azure.net:443/secrets/name/version"
            .parse()
            .unwrap();
        assert_eq!(
            deconstruct(&url).unwrap(),
            ResourceId {
                source_id: url.to_string(),
                vault_url: "https://vault.azure.net".into(),
                name: "name".into(),
                version: Some("version".into()),
            }
        );

        let url: Url = "https://vault.azure.net:8443/secrets/name/version"
            .parse()
            .unwrap();
        assert_eq!(
            deconstruct(&url).unwrap(),
            ResourceId {
                source_id: url.to_string(),
                vault_url: "https://vault.azure.net:8443".into(),
                name: "name".into(),
                version: Some("version".into()),
            }
        );
    }