style(arr): formatting

This commit is contained in:
Miguel Palhas
2026-08-25 06:28:20 +01:00
parent a836967e32
commit a4422e26e5
7 changed files with 57 additions and 27 deletions
+19 -12
View File
@@ -136,8 +136,12 @@ pub struct HealthReport {
pub async fn health(State(state): State<AppState>) -> Json<HealthReport> {
// Independent network probes; serialising them would make the endpoint
// as slow as the sum of the timeouts.
let (prowlarr, transmission, tmdb, subtitles) =
tokio::join!(probe_prowlarr(&state), probe_transmission(&state), probe_tmdb(&state), probe_subtitles(&state));
let (prowlarr, transmission, tmdb, subtitles) = tokio::join!(
probe_prowlarr(&state),
probe_transmission(&state),
probe_tmdb(&state),
probe_subtitles(&state)
);
let status = if [prowlarr.status, transmission.status, tmdb.status]
.into_iter()
@@ -307,9 +311,7 @@ fn check_from(result: Result<(), arr_subs::Error>) -> Check {
fn backend_check(result: Result<(), backend_error::Error>) -> Check {
match result {
Ok(()) => Check::ok(),
Err(backend_error::Error::Unauthorized { .. }) => {
Check::unreachable("credentials refused")
}
Err(backend_error::Error::Unauthorized { .. }) => Check::unreachable("credentials refused"),
Err(error) => Check::unreachable(error.to_string()),
}
}
@@ -330,11 +332,11 @@ mod tests {
use std::sync::Arc;
use arr_db::Db;
use arr_subs::translate as backend;
use arr_subs::{
Backend, CandidateId, DownloadFuture, Provider, ProviderId, SearchFuture, SearchRequest,
Syncer,
};
use arr_subs::translate as backend;
use crate::{router, AppState, Upstreams};
@@ -497,7 +499,10 @@ mod tests {
set_enabled(&state, r#"["ok","bad"]"#, None).await;
let state = state.with_subtitle_providers(vec![
Arc::new(StubProvider { id: "ok", up: true }),
Arc::new(StubProvider { id: "bad", up: false }),
Arc::new(StubProvider {
id: "bad",
up: false,
}),
]);
let body = report(state).await;
@@ -505,7 +510,10 @@ mod tests {
assert_eq!(body["subtitles"]["providers"][0]["status"], "ok");
assert_eq!(body["subtitles"]["providers"][1]["id"], "bad");
assert_eq!(body["subtitles"]["providers"][1]["status"], "unreachable");
assert_eq!(body["subtitles"]["providers"][1]["detail"], "credentials refused");
assert_eq!(
body["subtitles"]["providers"][1]["detail"],
"credentials refused"
);
}
#[tokio::test]
@@ -524,10 +532,9 @@ mod tests {
async fn an_unreachable_engine_fails_the_whole_report() {
let (_dir, state) = application().await;
set_enabled(&state, "[]", Some("openai")).await;
let state = state
.with_translation_backends(vec![Arc::new(StubBackend {
detail: "connection refused",
})]);
let state = state.with_translation_backends(vec![Arc::new(StubBackend {
detail: "connection refused",
})]);
let body = report(state).await;
assert_eq!(body["subtitles"]["translation"]["status"], "unreachable");
+14 -4
View File
@@ -58,7 +58,11 @@ impl SubtitleUpstreams {
let mut lamps = Vec::new();
for id in &providers_enabled {
let reachable = match self.providers.iter().find(|p| p.id().as_str() == id.as_str()) {
let reachable = match self
.providers
.iter()
.find(|p| p.id().as_str() == id.as_str())
{
Some(provider) => provider.probe().await.is_ok(),
None => false,
};
@@ -246,7 +250,9 @@ mod tests {
/// lamps the seed row would otherwise put in use.
async fn database() -> (tempfile::TempDir, Db) {
let dir = tempfile::tempdir().unwrap();
let db = Db::connect(dir.path().join("broken-test.db")).await.unwrap();
let db = Db::connect(dir.path().join("broken-test.db"))
.await
.unwrap();
db.migrate().await.unwrap();
sqlx::query("UPDATE subtitle_settings SET providers_enabled = '[]'")
.execute(db.pool())
@@ -320,7 +326,9 @@ mod tests {
.await;
let dir = tempfile::tempdir().unwrap();
let db = Db::connect(dir.path().join("broken-subs.db")).await.unwrap();
let db = Db::connect(dir.path().join("broken-subs.db"))
.await
.unwrap();
db.migrate().await.unwrap();
// The seed row already enables opensubtitles and podnapisi; none are
// attached to this action.
@@ -394,7 +402,9 @@ mod tests {
let first = action.tick(&db).await;
assert_eq!(first.len(), 1, "only the missing binary notifies");
assert!(
first.iter().any(|outcome| format!("{outcome:?}").contains("alass")),
first
.iter()
.any(|outcome| format!("{outcome:?}").contains("alass")),
"{first:?}"
);
}
+8 -2
View File
@@ -303,7 +303,8 @@ fn reconcile_loop(
tmdb: Option<&Arc<TmdbClient>>,
notifier: &Notifier,
translators: &Translators,
) -> Result<(ReconcileLoop, Option<GrabAction>, Option<TvGrabAction>), Error> { let reconcile = ReconcileLoop::new(database.clone());
) -> Result<(ReconcileLoop, Option<GrabAction>, Option<TvGrabAction>), Error> {
let reconcile = ReconcileLoop::new(database.clone());
let seeding = SeedingRules::new(
SeedingLimits {
ratio: config.seed_ratio_limit,
@@ -435,7 +436,12 @@ fn register_broken(
};
reconcile.register(
Tick::Reconcile,
BrokenAction::new(broken_upstreams, broken_subtitles, notifier.clone(), operator_topic),
BrokenAction::new(
broken_upstreams,
broken_subtitles,
notifier.clone(),
operator_topic,
),
)
}
+4 -1
View File
@@ -218,7 +218,10 @@ impl Backend for Command {
Box::pin(async move {
let payload = format!(
"{}\n[]\n",
system_prompt(&Language::Other("en".to_owned()), &Language::PortuguesePortugal)
system_prompt(
&Language::Other("en".to_owned()),
&Language::PortuguesePortugal
)
);
let mut tokens = argv(&self.config.template);
for token in &mut tokens {
+1 -3
View File
@@ -259,9 +259,7 @@ impl Provider for Podnapisi {
/// Anonymous, so the lamp is reachability alone (#200): the site root
/// answers, no quota spent.
fn probe(&self) -> crate::ProbeFuture<'_> {
Box::pin(async move {
self.send(self.base_url.clone(), None).await.map(|_| ())
})
Box::pin(async move { self.send(self.base_url.clone(), None).await.map(|_| ()) })
}
}
+1 -3
View File
@@ -704,8 +704,6 @@ mod tests {
)));
// `sh` is on PATH of every machine that runs these tests.
assert!(super::binary_present(std::ffi::OsStr::new("sh")));
assert!(Syncer::new()
.with_binary(executable.as_os_str())
.present());
assert!(Syncer::new().with_binary(executable.as_os_str()).present());
}
}