This is an automated email from the ASF dual-hosted git repository.

xuanwo pushed a commit to branch lazy-reader
in repository https://gitbox.apache.org/repos/asf/incubator-opendal.git

commit 196620246e9f3e523c0721ac56ce885db3e07d7d
Author: Xuanwo <[email protected]>
AuthorDate: Wed Oct 25 20:31:26 2023 +0800

    Fix tests
    
    Signed-off-by: Xuanwo <[email protected]>
---
 core/tests/behavior/blocking_copy.rs   | 16 +++++++++++++---
 core/tests/behavior/blocking_rename.rs | 16 +++++++++++++---
 core/tests/behavior/copy.rs            | 21 +++++++++++++++++----
 core/tests/behavior/rename.rs          | 16 +++++++++++++---
 4 files changed, 56 insertions(+), 13 deletions(-)

diff --git a/core/tests/behavior/blocking_copy.rs 
b/core/tests/behavior/blocking_copy.rs
index 822369a22..53b26e8f0 100644
--- a/core/tests/behavior/blocking_copy.rs
+++ b/core/tests/behavior/blocking_copy.rs
@@ -16,6 +16,7 @@
 // under the License.
 
 use anyhow::Result;
+use sha2::{Digest, Sha256};
 
 use crate::*;
 
@@ -50,7 +51,10 @@ pub fn test_blocking_copy_file(op: BlockingOperator) -> 
Result<()> {
     op.copy(&source_path, &target_path)?;
 
     let target_content = op.read(&target_path).expect("read must succeed");
-    assert_eq!(target_content, source_content);
+    assert_eq!(
+        format!("{:x}", Sha256::digest(&target_content)),
+        format!("{:x}", Sha256::digest(&source_content)),
+    );
 
     op.delete(&source_path).expect("delete must succeed");
     op.delete(&target_path).expect("delete must succeed");
@@ -137,7 +141,10 @@ pub fn test_blocking_copy_nested(op: BlockingOperator) -> 
Result<()> {
     op.copy(&source_path, &target_path)?;
 
     let target_content = op.read(&target_path).expect("read must succeed");
-    assert_eq!(target_content, source_content);
+    assert_eq!(
+        format!("{:x}", Sha256::digest(&target_content)),
+        format!("{:x}", Sha256::digest(&source_content)),
+    );
 
     op.delete(&source_path).expect("delete must succeed");
     op.delete(&target_path).expect("delete must succeed");
@@ -160,7 +167,10 @@ pub fn test_blocking_copy_overwrite(op: BlockingOperator) 
-> Result<()> {
     op.copy(&source_path, &target_path)?;
 
     let target_content = op.read(&target_path).expect("read must succeed");
-    assert_eq!(target_content, source_content);
+    assert_eq!(
+        format!("{:x}", Sha256::digest(&target_content)),
+        format!("{:x}", Sha256::digest(&source_content)),
+    );
 
     op.delete(&source_path).expect("delete must succeed");
     op.delete(&target_path).expect("delete must succeed");
diff --git a/core/tests/behavior/blocking_rename.rs 
b/core/tests/behavior/blocking_rename.rs
index 398a3f4da..24c1bc559 100644
--- a/core/tests/behavior/blocking_rename.rs
+++ b/core/tests/behavior/blocking_rename.rs
@@ -16,6 +16,7 @@
 // under the License.
 
 use anyhow::Result;
+use sha2::{Digest, Sha256};
 
 use crate::*;
 
@@ -53,7 +54,10 @@ pub fn test_blocking_rename_file(op: BlockingOperator) -> 
Result<()> {
     assert_eq!(err.kind(), ErrorKind::NotFound);
 
     let target_content = op.read(&target_path).expect("read must succeed");
-    assert_eq!(target_content, source_content);
+    assert_eq!(
+        format!("{:x}", Sha256::digest(&target_content)),
+        format!("{:x}", Sha256::digest(&source_content)),
+    );
 
     op.delete(&source_path).expect("delete must succeed");
     op.delete(&target_path).expect("delete must succeed");
@@ -143,7 +147,10 @@ pub fn test_blocking_rename_nested(op: BlockingOperator) 
-> Result<()> {
     assert_eq!(err.kind(), ErrorKind::NotFound);
 
     let target_content = op.read(&target_path).expect("read must succeed");
-    assert_eq!(target_content, source_content);
+    assert_eq!(
+        format!("{:x}", Sha256::digest(&target_content)),
+        format!("{:x}", Sha256::digest(&source_content)),
+    );
 
     op.delete(&source_path).expect("delete must succeed");
     op.delete(&target_path).expect("delete must succeed");
@@ -169,7 +176,10 @@ pub fn test_blocking_rename_overwrite(op: 
BlockingOperator) -> Result<()> {
     assert_eq!(err.kind(), ErrorKind::NotFound);
 
     let target_content = op.read(&target_path).expect("read must succeed");
-    assert_eq!(target_content, source_content);
+    assert_eq!(
+        format!("{:x}", Sha256::digest(&target_content)),
+        format!("{:x}", Sha256::digest(&source_content)),
+    );
 
     op.delete(&source_path).expect("delete must succeed");
     op.delete(&target_path).expect("delete must succeed");
diff --git a/core/tests/behavior/copy.rs b/core/tests/behavior/copy.rs
index b8a4573ba..7d65a2e6c 100644
--- a/core/tests/behavior/copy.rs
+++ b/core/tests/behavior/copy.rs
@@ -16,6 +16,7 @@
 // under the License.
 
 use anyhow::Result;
+use sha2::{Digest, Sha256};
 
 use crate::*;
 
@@ -51,7 +52,10 @@ pub async fn test_copy_file_with_ascii_name(op: Operator) -> 
Result<()> {
     op.copy(&source_path, &target_path).await?;
 
     let target_content = op.read(&target_path).await.expect("read must 
succeed");
-    assert_eq!(target_content, source_content);
+    assert_eq!(
+        format!("{:x}", Sha256::digest(&target_content)),
+        format!("{:x}", Sha256::digest(&source_content)),
+    );
 
     op.delete(&source_path).await.expect("delete must succeed");
     op.delete(&target_path).await.expect("delete must succeed");
@@ -68,7 +72,10 @@ pub async fn test_copy_file_with_non_ascii_name(op: 
Operator) -> Result<()> {
     op.copy(source_path, target_path).await?;
 
     let target_content = op.read(target_path).await.expect("read must 
succeed");
-    assert_eq!(target_content, source_content);
+    assert_eq!(
+        format!("{:x}", Sha256::digest(&target_content)),
+        format!("{:x}", Sha256::digest(&source_content)),
+    );
 
     op.delete(source_path).await.expect("delete must succeed");
     op.delete(target_path).await.expect("delete must succeed");
@@ -159,7 +166,10 @@ pub async fn test_copy_nested(op: Operator) -> Result<()> {
     op.copy(&source_path, &target_path).await?;
 
     let target_content = op.read(&target_path).await.expect("read must 
succeed");
-    assert_eq!(target_content, source_content);
+    assert_eq!(
+        format!("{:x}", Sha256::digest(&target_content)),
+        format!("{:x}", Sha256::digest(&source_content)),
+    );
 
     op.delete(&source_path).await.expect("delete must succeed");
     op.delete(&target_path).await.expect("delete must succeed");
@@ -182,7 +192,10 @@ pub async fn test_copy_overwrite(op: Operator) -> 
Result<()> {
     op.copy(&source_path, &target_path).await?;
 
     let target_content = op.read(&target_path).await.expect("read must 
succeed");
-    assert_eq!(target_content, source_content);
+    assert_eq!(
+        format!("{:x}", Sha256::digest(&target_content)),
+        format!("{:x}", Sha256::digest(&source_content)),
+    );
 
     op.delete(&source_path).await.expect("delete must succeed");
     op.delete(&target_path).await.expect("delete must succeed");
diff --git a/core/tests/behavior/rename.rs b/core/tests/behavior/rename.rs
index ac4974c8f..8880e16c8 100644
--- a/core/tests/behavior/rename.rs
+++ b/core/tests/behavior/rename.rs
@@ -16,6 +16,7 @@
 // under the License.
 
 use anyhow::Result;
+use sha2::{Digest, Sha256};
 
 use crate::*;
 
@@ -53,7 +54,10 @@ pub async fn test_rename_file(op: Operator) -> Result<()> {
     assert_eq!(err.kind(), ErrorKind::NotFound);
 
     let target_content = op.read(&target_path).await.expect("read must 
succeed");
-    assert_eq!(target_content, source_content);
+    assert_eq!(
+        format!("{:x}", Sha256::digest(&target_content)),
+        format!("{:x}", Sha256::digest(&source_content)),
+    );
 
     op.delete(&source_path).await.expect("delete must succeed");
     op.delete(&target_path).await.expect("delete must succeed");
@@ -147,7 +151,10 @@ pub async fn test_rename_nested(op: Operator) -> 
Result<()> {
     assert_eq!(err.kind(), ErrorKind::NotFound);
 
     let target_content = op.read(&target_path).await.expect("read must 
succeed");
-    assert_eq!(target_content, source_content);
+    assert_eq!(
+        format!("{:x}", Sha256::digest(&target_content)),
+        format!("{:x}", Sha256::digest(&source_content)),
+    );
 
     op.delete(&source_path).await.expect("delete must succeed");
     op.delete(&target_path).await.expect("delete must succeed");
@@ -173,7 +180,10 @@ pub async fn test_rename_overwrite(op: Operator) -> 
Result<()> {
     assert_eq!(err.kind(), ErrorKind::NotFound);
 
     let target_content = op.read(&target_path).await.expect("read must 
succeed");
-    assert_eq!(target_content, source_content);
+    assert_eq!(
+        format!("{:x}", Sha256::digest(&target_content)),
+        format!("{:x}", Sha256::digest(&source_content)),
+    );
 
     op.delete(&source_path).await.expect("delete must succeed");
     op.delete(&target_path).await.expect("delete must succeed");

Reply via email to