Skip to content

Commit

Permalink
fix unit tests password of test_get_ovf_env_missing_* (#32)
Browse files Browse the repository at this point in the history
Fix failures in unit tests `test_get_ovf_env_missing_password`,
`test_get_ovf_env_missing_three`, by checking for errors instead of
actual values.
As `parse_ovf_env` is expected to return errors if the password is
empty, it is not necessary to check other returned fields.

Fixes #30

## Testing done

`cargo test` passed
  • Loading branch information
dongsupark committed Jan 31, 2024
1 parent 40aaece commit 3068896
Showing 1 changed file with 10 additions and 74 deletions.
84 changes: 10 additions & 74 deletions src/media.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,43 +328,11 @@ mod tests {
</wa:PlatformSettingsSection>
</Environment>"#;

let environment: Environment = parse_ovf_env(ovf_body).unwrap();

assert_eq!(
environment
.provisioning_section
.linux_prov_conf_set
.username,
"myusername"
);
assert_eq!(
environment
.provisioning_section
.linux_prov_conf_set
.password,
""
);
assert_eq!(
environment
.provisioning_section
.linux_prov_conf_set
.hostname,
"myhostname"
);
assert_eq!(
environment
.platform_settings_section
.platform_settings
.preprovisioned_vm,
true
);
assert_eq!(
environment
.platform_settings_section
.platform_settings
.preprovisioned_vm_type,
"None"
);
assert!(parse_ovf_env(ovf_body)
.err()
.unwrap()
.downcast::<std::io::Error>()
.is_err());
}

#[test]
Expand Down Expand Up @@ -398,42 +366,10 @@ mod tests {
</wa:PlatformSettingsSection>
</Environment>"#;

let environment: Environment = parse_ovf_env(ovf_body).unwrap();

assert_eq!(
environment
.provisioning_section
.linux_prov_conf_set
.username,
"myusername"
);
assert_eq!(
environment
.provisioning_section
.linux_prov_conf_set
.password,
""
);
assert_eq!(
environment
.provisioning_section
.linux_prov_conf_set
.hostname,
"myhostname"
);
assert_eq!(
environment
.platform_settings_section
.platform_settings
.preprovisioned_vm,
false
);
assert_eq!(
environment
.platform_settings_section
.platform_settings
.preprovisioned_vm_type,
"None"
);
assert!(parse_ovf_env(ovf_body)
.err()
.unwrap()
.downcast::<std::io::Error>()
.is_err());
}
}

0 comments on commit 3068896

Please sign in to comment.