Skip to content

Commit

Permalink
test: tag up tests with features
Browse files Browse the repository at this point in the history
  • Loading branch information
Mollemoll committed May 16, 2024
1 parent 4dd3b6b commit 645fe95
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/ch_vat/bfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ impl Verifier for Bfs {
mod tests {
use super::*;

#[cfg(feature = "ch_vat")]
#[test]
fn test_bfs_xml_to_hash() {
let xml = r#"
Expand All @@ -142,6 +143,7 @@ mod tests {
assert_eq!(hash.get("ValidateVatNumberResult"), Some(&Some("true".to_string())));
}

#[cfg(feature = "ch_vat")]
#[test]
fn test_parse_response_verified() {
let response = VerificationResponse::new(
Expand All @@ -166,6 +168,7 @@ mod tests {
}));
}

#[cfg(feature = "ch_vat")]
#[test]
fn test_parse_response_unverified() {
let response = VerificationResponse::new(
Expand All @@ -190,6 +193,7 @@ mod tests {
}));
}

#[cfg(feature = "ch_vat")]
#[test]
fn test_parse_response_unavailable() {
let response = VerificationResponse::new(
Expand Down Expand Up @@ -226,6 +230,7 @@ mod tests {
}));
}

#[cfg(feature = "ch_vat")]
#[test]
fn test_parse_response_unavailable_unexpected_faultstring() {
let response = VerificationResponse::new(
Expand Down Expand Up @@ -253,6 +258,7 @@ mod tests {
}
}

#[cfg(feature = "ch_vat")]
#[test]
fn test_parse_response_unexpected_response_value() {
let response = VerificationResponse::new(
Expand All @@ -279,6 +285,7 @@ mod tests {
}
}

#[cfg(feature = "ch_vat")]
#[test]
fn test_parse_response_empty_response_value() {
let response = VerificationResponse::new(
Expand Down
1 change: 1 addition & 0 deletions src/ch_vat/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ impl TaxIdType for ChVat {
mod tests {
use super::*;

#[cfg(feature = "ch_vat")]
#[test]
fn test_ch_vats() {
let valid_vat_numbers = vec![
Expand Down
28 changes: 28 additions & 0 deletions src/eu_vat/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ mod tests {
}
}

#[cfg(feature = "eu_vat")]
#[test]
fn test_at_vat() {
let valid_vat_numbers = vec!["ATU12345678", "ATU87654321"];
Expand All @@ -73,6 +74,7 @@ mod tests {
assert_validations(valid_vat_numbers, invalid_vat_numbers);
}

#[cfg(feature = "eu_vat")]
#[test]
fn test_be_vat() {
let valid_vat_numbers = vec!["BE0123456789", "BE0987654321"];
Expand All @@ -86,6 +88,7 @@ mod tests {
assert_validations(valid_vat_numbers, invalid_vat_numbers);
}

#[cfg(feature = "eu_vat")]
#[test]
fn test_bg_vat() {
let valid_vat_numbers = vec!["BG123456789", "BG1234567890"];
Expand All @@ -94,6 +97,7 @@ mod tests {
assert_validations(valid_vat_numbers, invalid_vat_numbers);
}

#[cfg(feature = "eu_vat")]
#[test]
fn test_cy_vat() {
let valid_vat_numbers = vec!["CY12345678A", "CY98765432Z"];
Expand All @@ -102,6 +106,7 @@ mod tests {
assert_validations(valid_vat_numbers, invalid_vat_numbers);
}

#[cfg(feature = "eu_vat")]
#[test]
fn test_cz_vat() {
let valid_vat_numbers = vec!["CZ12345678", "CZ123456789", "CZ1234567890"];
Expand All @@ -110,6 +115,7 @@ mod tests {
assert_validations(valid_vat_numbers, invalid_vat_numbers);
}

#[cfg(feature = "eu_vat")]
#[test]
fn test_de_vat() {
let valid_vat_numbers = vec!["DE123456789", "DE987654321"];
Expand All @@ -118,6 +124,7 @@ mod tests {
assert_validations(valid_vat_numbers, invalid_vat_numbers);
}

#[cfg(feature = "eu_vat")]
#[test]
fn test_dk_vat() {
let valid_vat_numbers = vec!["DK12345678"];
Expand All @@ -126,6 +133,7 @@ mod tests {
assert_validations(valid_vat_numbers, invalid_vat_numbers);
}

#[cfg(feature = "eu_vat")]
#[test]
fn test_ee_vat() {
let valid_vat_numbers = vec!["EE101234567"];
Expand All @@ -134,6 +142,7 @@ mod tests {
assert_validations(valid_vat_numbers, invalid_vat_numbers);
}

#[cfg(feature = "eu_vat")]
#[test]
fn test_el_vat() {
let valid_vat_numbers = vec!["EL123456789"];
Expand All @@ -142,6 +151,7 @@ mod tests {
assert_validations(valid_vat_numbers, invalid_vat_numbers);
}

#[cfg(feature = "eu_vat")]
#[test]
fn test_es_vat() {
let valid_vat_numbers = vec!["ESX12345678", "ES12345678Z", "ESX1234567Z"];
Expand All @@ -150,6 +160,7 @@ mod tests {
assert_validations(valid_vat_numbers, invalid_vat_numbers);
}

#[cfg(feature = "eu_vat")]
#[test]
fn test_fi_vat() {
let valid_vat_numbers = vec!["FI12345678"];
Expand All @@ -158,6 +169,7 @@ mod tests {
assert_validations(valid_vat_numbers, invalid_vat_numbers);
}

#[cfg(feature = "eu_vat")]
#[test]
fn test_fr_vat() {
let valid_vat_numbers = vec!["FR12345678901", "FRX1234567890"];
Expand All @@ -166,6 +178,7 @@ mod tests {
assert_validations(valid_vat_numbers, invalid_vat_numbers);
}

#[cfg(feature = "eu_vat")]
#[test]
fn test_hr_vat() {
let valid_vat_numbers = vec!["HR12345678901"];
Expand All @@ -174,6 +187,7 @@ mod tests {
assert_validations(valid_vat_numbers, invalid_vat_numbers);
}

#[cfg(feature = "eu_vat")]
#[test]
fn test_hu_vat() {
let valid_vat_numbers = vec!["HU12345678"];
Expand All @@ -182,6 +196,7 @@ mod tests {
assert_validations(valid_vat_numbers, invalid_vat_numbers);
}

#[cfg(feature = "eu_vat")]
#[test]
fn test_ie_vat() {
let valid_vat_numbers = vec!["IE1234567A", "IE1A23456A", "IE1234567AA"];
Expand All @@ -190,6 +205,7 @@ mod tests {
assert_validations(valid_vat_numbers, invalid_vat_numbers);
}

#[cfg(feature = "eu_vat")]
#[test]
fn test_it_vat() {
let valid_vat_numbers = vec!["IT12345678901"];
Expand All @@ -198,6 +214,7 @@ mod tests {
assert_validations(valid_vat_numbers, invalid_vat_numbers);
}

#[cfg(feature = "eu_vat")]
#[test]
fn test_lt_vat() {
let valid_vat_numbers = vec!["LT999999919", "LT999999919"];
Expand All @@ -206,6 +223,7 @@ mod tests {
assert_validations(valid_vat_numbers, invalid_vat_numbers);
}

#[cfg(feature = "eu_vat")]
#[test]
fn test_lu_vat() {
let valid_vat_numbers = vec!["LU12345678"];
Expand All @@ -214,6 +232,7 @@ mod tests {
assert_validations(valid_vat_numbers, invalid_vat_numbers);
}

#[cfg(feature = "eu_vat")]
#[test]
fn test_lv_vat() {
let valid_vat_numbers = vec!["LV12345678901"];
Expand All @@ -222,6 +241,7 @@ mod tests {
assert_validations(valid_vat_numbers, invalid_vat_numbers);
}

#[cfg(feature = "eu_vat")]
#[test]
fn test_mt_vat() {
let valid_vat_numbers = vec!["MT12345678"];
Expand All @@ -230,6 +250,7 @@ mod tests {
assert_validations(valid_vat_numbers, invalid_vat_numbers);
}

#[cfg(feature = "eu_vat")]
#[test]
fn test_nl_vat() {
let valid_vat_numbers = vec!["NL123456789B01"];
Expand All @@ -238,6 +259,7 @@ mod tests {
assert_validations(valid_vat_numbers, invalid_vat_numbers);
}

#[cfg(feature = "eu_vat")]
#[test]
fn test_pl_vat() {
let valid_vat_numbers = vec!["PL1234567890"];
Expand All @@ -246,6 +268,7 @@ mod tests {
assert_validations(valid_vat_numbers, invalid_vat_numbers);
}

#[cfg(feature = "eu_vat")]
#[test]
fn test_pt_vat() {
let valid_vat_numbers = vec!["PT123456789"];
Expand All @@ -254,6 +277,7 @@ mod tests {
assert_validations(valid_vat_numbers, invalid_vat_numbers);
}

#[cfg(feature = "eu_vat")]
#[test]
fn test_ro_vat() {
let valid_vat_numbers = vec!["RO99999999", "RO999999999"];
Expand All @@ -262,6 +286,7 @@ mod tests {
assert_validations(valid_vat_numbers, invalid_vat_numbers);
}

#[cfg(feature = "eu_vat")]
#[test]
fn test_se_vat() {
let valid_vat_numbers = vec!["SE123456789101"];
Expand All @@ -270,6 +295,7 @@ mod tests {
assert_validations(valid_vat_numbers, invalid_vat_numbers);
}

#[cfg(feature = "eu_vat")]
#[test]
fn test_si_vat() {
let valid_vat_numbers = vec!["SI12345678"];
Expand All @@ -278,6 +304,7 @@ mod tests {
assert_validations(valid_vat_numbers, invalid_vat_numbers);
}

#[cfg(feature = "eu_vat")]
#[test]
fn test_sk_vat() {
let valid_vat_numbers = vec!["SK1234567890"];
Expand All @@ -286,6 +313,7 @@ mod tests {
assert_validations(valid_vat_numbers, invalid_vat_numbers);
}

#[cfg(feature = "eu_vat")]
#[test]
fn test_xi_vat() {
let valid_vat_numbers = vec!["XI123456789", "XI987654321", "XIHA123", "XIGD123"];
Expand Down
2 changes: 2 additions & 0 deletions src/eu_vat/syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ lazy_static! {
mod tests {
use super::*;
use crate::eu_vat::COUNTRIES;

#[cfg(feature = "eu_vat")]
#[test]
fn test_each_eu_country_has_a_regex() {
let mut eu_regex_countries = EU_VAT_PATTERNS.keys().collect::<Vec<&String>>();
Expand Down
6 changes: 6 additions & 0 deletions src/eu_vat/vies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ impl Verifier for Vies {
mod tests {
use super::*;

#[cfg(feature = "eu_vat")]
#[test]
fn test_xml_to_hash() {
let xml = r#"
Expand Down Expand Up @@ -183,6 +184,7 @@ mod tests {
assert_eq!(hash.get("address"), Some(&None));
}

#[cfg(feature = "eu_vat")]
#[test]
fn test_parse_response_verified() {
let response = VerificationResponse::new(
Expand All @@ -209,6 +211,7 @@ mod tests {
assert_eq!(verification.status(), &VerificationStatus::Verified);
}

#[cfg(feature = "eu_vat")]
#[test]
fn test_parse_response_unverified() {
let response = VerificationResponse::new(
Expand All @@ -235,6 +238,7 @@ mod tests {
assert_eq!(verification.status(), &VerificationStatus::Unverified);
}

#[cfg(feature = "eu_vat")]
#[test]
fn test_parse_response_unavailable() {
let response = VerificationResponse::new(
Expand All @@ -261,6 +265,7 @@ mod tests {
}));
}

#[cfg(feature = "eu_vat")]
#[test]
fn test_parse_response_missing_valid_field() {
let response = VerificationResponse::new(
Expand All @@ -287,6 +292,7 @@ mod tests {
}
}

#[cfg(feature = "eu_vat")]
#[test]
fn test_parse_response_invalid_validity_value() {
let response = VerificationResponse::new(
Expand Down
4 changes: 4 additions & 0 deletions src/gb_vat/hmrc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use crate::verification::UnavailableReason::ServiceUnavailable;

static BASE_URI: &'static str = "https://api.service.hmrc.gov.uk/organisations/vat/check-vat-number/lookup";
const NOT_FOUND: &str = "NOT_FOUND";
#[allow(dead_code)]
const SERVER_ERROR: &str = "SERVER_ERROR";


Expand Down Expand Up @@ -69,6 +70,7 @@ impl Verifier for Hmrc {
mod tests {
use super::*;

#[cfg(feature = "gb_vat")]
#[test]
fn test_parse_response_verified() {
let response = VerificationResponse::new(
Expand Down Expand Up @@ -108,6 +110,7 @@ mod tests {
}));
}

#[cfg(feature = "gb_vat")]
#[test]
fn test_parse_response_unverified() {
let response = VerificationResponse::new(
Expand All @@ -128,6 +131,7 @@ mod tests {
}));
}

#[cfg(feature = "gb_vat")]
#[test]
fn test_parse_response_unavailable() {
let response = VerificationResponse::new(
Expand Down
1 change: 1 addition & 0 deletions src/gb_vat/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ mod tests {
use crate::gb_vat::GbVat;
use crate::TaxIdType;

#[cfg(feature = "gb_vat")]
#[test]
fn test_gb_vat() {
let valid_vat_numbers = vec![
Expand Down
Loading

0 comments on commit 645fe95

Please sign in to comment.