Allow unwrap() in tests when clippy::unwrap_used is denied (#11616)

## Problem

The proxy denies using `unwrap()`s in regular code, but we want to use
it in test code
and so have to allow it for each test block.

## Summary of changes

Set `allow-unwrap-in-tests = true` in clippy.toml and remove all
exceptions.
This commit is contained in:
Folke Behrens
2025-04-16 20:05:21 +00:00
committed by GitHub
parent b9b25e13a0
commit ec9079f483
25 changed files with 4 additions and 24 deletions

View File

@@ -12,3 +12,5 @@ disallowed-macros = [
# cannot disallow this, because clippy finds used from tokio macros
#"tokio::pin",
]
allow-unwrap-in-tests = true

View File

@@ -776,7 +776,6 @@ impl From<&jose_jwk::Key> for KeyType {
}
#[cfg(test)]
#[expect(clippy::unwrap_used)]
mod tests {
use std::future::IntoFuture;
use std::net::SocketAddr;

View File

@@ -253,7 +253,6 @@ fn project_name_valid(name: &str) -> bool {
}
#[cfg(test)]
#[expect(clippy::unwrap_used)]
mod tests {
use ComputeUserInfoParseError::*;
use serde_json::json;

View File

@@ -259,7 +259,6 @@ impl EndpointsCache {
}
#[cfg(test)]
#[expect(clippy::unwrap_used)]
mod tests {
use super::*;

View File

@@ -585,7 +585,6 @@ impl Cache for ProjectInfoCacheImpl {
}
#[cfg(test)]
#[expect(clippy::unwrap_used)]
mod tests {
use super::*;
use crate::scram::ServerSecret;

View File

@@ -416,7 +416,6 @@ async fn upload_parquet(
}
#[cfg(test)]
#[expect(clippy::unwrap_used)]
mod tests {
use std::net::Ipv4Addr;
use std::num::NonZeroUsize;

View File

@@ -227,7 +227,6 @@ impl From<AccountId> for AccountIdInt {
}
#[cfg(test)]
#[expect(clippy::unwrap_used)]
mod tests {
use std::sync::OnceLock;

View File

@@ -1032,7 +1032,6 @@ impl<const F: usize> serde::ser::Serialize for ExtractedSpanFields<'_, F> {
}
#[cfg(test)]
#[allow(clippy::unwrap_used)]
mod tests {
use std::marker::PhantomData;
use std::sync::{Arc, Mutex, MutexGuard};

View File

@@ -400,7 +400,6 @@ impl NetworkEndianIpv6 {
}
#[cfg(test)]
#[expect(clippy::unwrap_used)]
mod tests {
use tokio::io::AsyncReadExt;

View File

@@ -262,7 +262,6 @@ impl CopyBuffer {
}
#[cfg(test)]
#[expect(clippy::unwrap_used)]
mod tests {
use tokio::io::AsyncWriteExt;

View File

@@ -1,5 +1,5 @@
//! A group of high-level tests for connection establishing logic and auth.
#![allow(clippy::unimplemented, clippy::unwrap_used)]
#![allow(clippy::unimplemented)]
mod mitm;

View File

@@ -83,7 +83,7 @@ impl From<LeakyBucketConfig> for utils::leaky_bucket::LeakyBucketConfig {
}
#[cfg(test)]
#[allow(clippy::float_cmp, clippy::unwrap_used)]
#[allow(clippy::float_cmp)]
mod tests {
use std::time::Duration;

View File

@@ -63,7 +63,6 @@ impl LimitAlgorithm for Aimd {
}
#[cfg(test)]
#[expect(clippy::unwrap_used)]
mod tests {
use std::time::Duration;

View File

@@ -259,7 +259,6 @@ impl<K: Hash + Eq, R: Rng, S: BuildHasher + Clone> BucketRateLimiter<K, R, S> {
}
#[cfg(test)]
#[expect(clippy::unwrap_used)]
mod tests {
use std::hash::BuildHasherDefault;
use std::time::Duration;

View File

@@ -51,7 +51,6 @@ impl<'a> ServerMessage<&'a str> {
}
#[cfg(test)]
#[expect(clippy::unwrap_used)]
mod tests {
use super::*;

View File

@@ -185,7 +185,6 @@ impl fmt::Debug for OwnedServerFirstMessage {
}
#[cfg(test)]
#[expect(clippy::unwrap_used)]
mod tests {
use super::*;

View File

@@ -57,7 +57,6 @@ fn sha256<'a>(parts: impl IntoIterator<Item = &'a [u8]>) -> [u8; 32] {
}
#[cfg(test)]
#[expect(clippy::unwrap_used)]
mod tests {
use super::threadpool::ThreadPool;
use super::{Exchange, ServerSecret};

View File

@@ -72,7 +72,6 @@ impl ServerSecret {
}
#[cfg(test)]
#[expect(clippy::unwrap_used)]
mod tests {
use super::*;

View File

@@ -189,7 +189,6 @@ impl ClientDataRemote {
}
#[cfg(test)]
#[expect(clippy::unwrap_used)]
mod tests {
use std::sync::atomic::AtomicBool;

View File

@@ -256,7 +256,6 @@ fn pg_array_parse_inner(
}
#[cfg(test)]
#[expect(clippy::unwrap_used)]
mod tests {
use serde_json::json;

View File

@@ -367,7 +367,6 @@ fn sign_jwt(sk: &SigningKey, payload: &[u8]) -> String {
}
#[cfg(test)]
#[expect(clippy::unwrap_used)]
mod tests {
use ed25519_dalek::SigningKey;
use typed_json::json;

View File

@@ -1209,7 +1209,6 @@ impl Discard<'_> {
}
#[cfg(test)]
#[expect(clippy::unwrap_used)]
mod tests {
use super::*;

View File

@@ -177,7 +177,6 @@ pub(crate) async fn serve_websocket(
}
#[cfg(test)]
#[expect(clippy::unwrap_used)]
mod tests {
use std::pin::pin;

View File

@@ -50,7 +50,6 @@ impl std::fmt::Display for ApiUrl {
}
#[cfg(test)]
#[expect(clippy::unwrap_used)]
mod tests {
use super::*;

View File

@@ -497,7 +497,6 @@ async fn upload_backup_events(
}
#[cfg(test)]
#[expect(clippy::unwrap_used)]
mod tests {
use std::fs;
use std::io::BufReader;