Skip to content

Commit

Permalink
Satisfy clippy (#784)
Browse files Browse the repository at this point in the history
The only nontrivial change was switching from `std::sync::Mutex` to
`tokio::sync::Mutex` because the mutex was held across calls to
`.await`, following the [official guidance from
Tokio](https://tokio.rs/tokio/tutorial/shared-state#on-using-stdsyncmutex-and-tokiosyncmutex).
  • Loading branch information
michaelsilver authored Jul 12, 2024
1 parent 02023fb commit ad766c3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
7 changes: 2 additions & 5 deletions plane/plane-tests/tests/common/docker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,8 @@ impl Container {

while let Some(next) = stream.next().await {
let chunk = next?;
match chunk {
LogOutput::StdOut { message } => {
stdout_buffer.extend(message);
}
_ => {}
if let LogOutput::StdOut { message } = chunk {
stdout_buffer.extend(message);
}
}

Expand Down
6 changes: 3 additions & 3 deletions plane/plane-tests/tests/common/test_env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const TEST_CLUSTER: &str = "plane.test";
#[derive(Clone)]
pub struct TestEnvironment {
pub scratch_dir: PathBuf,
db: Arc<Mutex<Option<DevDatabase>>>,
db: Arc<tokio::sync::Mutex<Option<DevDatabase>>>, // held across await, see: https://tokio.rs/tokio/tutorial/shared-state#on-using-stdsyncmutex-and-tokiosyncmutex
drop_futures: Arc<Mutex<Vec<Arc<dyn AsyncDrop>>>>,
log_subscription: Arc<Mutex<Option<LogSubscription>>>,
pub run_name: String,
Expand Down Expand Up @@ -61,7 +61,7 @@ impl TestEnvironment {
self.log_subscription.lock().unwrap().take();

// Dump the database.
if let Some(db) = self.db.lock().unwrap().take() {
if let Some(db) = self.db.lock().await.take() {
db.drop_future().await.unwrap();
}

Expand All @@ -77,7 +77,7 @@ impl TestEnvironment {
}

pub async fn db(&mut self) -> PlaneDatabase {
let mut db_lock = self.db.lock().unwrap();
let mut db_lock = self.db.lock().await;
if db_lock.is_none() {
let db = DevDatabase::start(self)
.await
Expand Down
2 changes: 1 addition & 1 deletion plane/src/client/sse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ mod tests {

let stream = stream! {
loop {
if let Ok(_) = timeout(Duration::from_millis(100), receiver.recv()).await {
if (timeout(Duration::from_millis(100), receiver.recv()).await).is_ok() {
break;
};

Expand Down

0 comments on commit ad766c3

Please sign in to comment.