feat(arr): probe methods for subtitle providers and engines
This commit is contained in:
@@ -424,3 +424,42 @@ async fn an_id_this_provider_never_offered_is_not_found() {
|
||||
other => panic!("expected NotFound, got {other:?}"),
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn a_probe_passes_when_the_key_is_accepted_even_on_a_refused_request() {
|
||||
let server = MockServer::start().await;
|
||||
// An unparseable candidate id is rejected *after* authentication: any
|
||||
// 4xx short of 401/403 is proof the key was accepted, and spends no
|
||||
// search quota (#200).
|
||||
Mock::given(method("GET"))
|
||||
.and(path("/api/v1/subtitles"))
|
||||
.respond_with(ResponseTemplate::new(400))
|
||||
.mount(&server)
|
||||
.await;
|
||||
|
||||
client(&server)
|
||||
.probe()
|
||||
.await
|
||||
.expect("a refused request still proves the key");
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn a_probe_reports_refused_credentials_and_outages() {
|
||||
let server = MockServer::start().await;
|
||||
Mock::given(method("GET"))
|
||||
.and(path("/api/v1/subtitles"))
|
||||
.respond_with(ResponseTemplate::new(401))
|
||||
.mount(&server)
|
||||
.await;
|
||||
let err = client(&server).probe().await.expect_err("bad key");
|
||||
assert!(matches!(err, Error::Unauthorized { .. }));
|
||||
|
||||
server.reset().await;
|
||||
Mock::given(method("GET"))
|
||||
.and(path("/api/v1/subtitles"))
|
||||
.respond_with(ResponseTemplate::new(500))
|
||||
.mount(&server)
|
||||
.await;
|
||||
let err = client(&server).probe().await.expect_err("outage");
|
||||
assert!(matches!(err, Error::Malformed { .. }));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user