Skip to content

Commit e80dd22

Browse files
committed
fix: address clippy unnecessary_unwrap warnings in tests
1 parent ff0c90e commit e80dd22

1 file changed

Lines changed: 14 additions & 16 deletions

File tree

tests/lifecycle_integration.rs

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,8 @@ async fn test_container_pause_unpause() {
6363
let _ = StartCommand::new(&container_name).execute().await;
6464

6565
// Pause the container
66-
let pause_result = PauseCommand::new(&container_name).execute().await;
67-
if pause_result.is_ok() {
68-
assert!(!pause_result.unwrap().stdout.is_empty());
66+
if let Ok(pause_output) = PauseCommand::new(&container_name).execute().await {
67+
assert!(!pause_output.stdout.is_empty());
6968

7069
// Unpause the container
7170
let unpause_result = UnpauseCommand::new(&container_name)
@@ -100,8 +99,8 @@ async fn test_container_restart() {
10099
.execute()
101100
.await;
102101

103-
if restart_result.is_ok() {
104-
assert!(!restart_result.unwrap().stdout.is_empty());
102+
if let Ok(restart_output) = restart_result {
103+
assert!(!restart_output.stdout.is_empty());
105104
}
106105

107106
// Clean up
@@ -125,8 +124,8 @@ async fn test_container_rename() {
125124
// Rename the container
126125
let rename_result = RenameCommand::new(&old_name, &new_name).execute().await;
127126

128-
if rename_result.is_ok() {
129-
assert!(!rename_result.unwrap().stderr.contains("Error"));
127+
if let Ok(rename_output) = rename_result {
128+
assert!(!rename_output.stderr.contains("Error"));
130129
// Clean up with new name
131130
let _ = RmCommand::new(&new_name).force().execute().await;
132131
} else {
@@ -156,8 +155,8 @@ async fn test_container_kill() {
156155
.execute()
157156
.await;
158157

159-
if kill_result.is_ok() {
160-
assert!(!kill_result.unwrap().stdout.is_empty());
158+
if let Ok(kill_output) = kill_result {
159+
assert!(!kill_output.stdout.is_empty());
161160
}
162161

163162
// Clean up
@@ -184,8 +183,8 @@ async fn test_container_update() {
184183
.execute()
185184
.await;
186185

187-
if update_result.is_ok() {
188-
assert!(!update_result.unwrap().stdout.is_empty());
186+
if let Ok(update_output) = update_result {
187+
assert!(!update_output.stdout.is_empty());
189188
}
190189

191190
// Clean up
@@ -210,10 +209,9 @@ async fn test_container_wait() {
210209
// Wait for container to exit
211210
let wait_result = WaitCommand::new(&container_name).execute().await;
212211

213-
if wait_result.is_ok() {
214-
let output = wait_result.unwrap();
212+
if let Ok(wait_output) = wait_result {
215213
// The output should contain the exit code (0)
216-
assert!(output.stdout.contains("0"));
214+
assert!(wait_output.stdout.contains("0"));
217215
}
218216

219217
// Clean up
@@ -243,8 +241,8 @@ async fn test_container_commit() {
243241
.execute()
244242
.await;
245243

246-
if commit_result.is_ok() {
247-
assert!(!commit_result.unwrap().stdout.is_empty());
244+
if let Ok(commit_output) = commit_result {
245+
assert!(!commit_output.stdout.is_empty());
248246

249247
// Clean up the image
250248
let _ = docker_wrapper::RmiCommand::new(format!("{}:latest", image_name))

0 commit comments

Comments
 (0)