ci: add nightly external contract tests

This commit is contained in:
2026-06-13 11:20:03 +02:00
parent c35f8cce14
commit b910e77460
3 changed files with 94 additions and 0 deletions

View File

@@ -0,0 +1,56 @@
use pokedex_api::{
clients::{funtranslations::TranslationClient, pokeapi::PokeApiClient},
domain::TranslationKind,
};
use std::time::Duration;
const POKEAPI_BASE_URL: &str = "https://pokeapi.co/api/v2";
const FUN_TRANSLATIONS_BASE_URL: &str = "https://api.funtranslations.mercxry.me/v1";
const CONTRACT_TIMEOUT: Duration = Duration::from_secs(10);
#[tokio::test]
#[ignore = "nightly external contract test: calls the real PokéAPI"]
async fn pokeapi_species_contract_still_matches_what_we_parse() {
let client =
PokeApiClient::new(POKEAPI_BASE_URL, CONTRACT_TIMEOUT).expect("client should build");
let pokemon = client
.get_pokemon_info("mewtwo")
.await
.expect("PokéAPI species contract should still parse");
assert_eq!(pokemon.name, "mewtwo");
assert_eq!(pokemon.habitat, "rare");
assert!(pokemon.is_legendary);
assert!(!pokemon.description.trim().is_empty());
}
#[tokio::test]
#[ignore = "nightly external contract test: calls the real FunTranslations API"]
async fn funtranslations_yoda_contract_still_matches_what_we_parse() {
let client = TranslationClient::new(FUN_TRANSLATIONS_BASE_URL, CONTRACT_TIMEOUT)
.expect("client should build");
let translated = client
.translate(TranslationKind::Yoda, "It was created by science.")
.await
.expect("FunTranslations Yoda contract should still parse");
assert!(!translated.trim().is_empty());
assert_ne!(translated, "It was created by science.");
}
#[tokio::test]
#[ignore = "nightly external contract test: calls the real FunTranslations API"]
async fn funtranslations_shakespeare_contract_still_matches_what_we_parse() {
let client = TranslationClient::new(FUN_TRANSLATIONS_BASE_URL, CONTRACT_TIMEOUT)
.expect("client should build");
let translated = client
.translate(TranslationKind::Shakespeare, "You have a great friend.")
.await
.expect("FunTranslations Shakespeare contract should still parse");
assert!(!translated.trim().is_empty());
assert_ne!(translated, "You have a great friend.");
}