diff --git a/bin/ofs/tests/common/mod.rs b/bin/ofs/tests/common/mod.rs index 394d10622b5a..6be64c0faa6d 100644 --- a/bin/ofs/tests/common/mod.rs +++ b/bin/ofs/tests/common/mod.rs @@ -32,6 +32,8 @@ static RUNTIME: OnceLock = OnceLock::new(); pub struct OfsTestContext { pub mount_point: TempDir, + // This is a false positive, the field is used in the test. + #[allow(dead_code)] pub capability: Capability, mount_handle: MountHandle, } diff --git a/core/src/raw/version.rs b/core/src/raw/version.rs index 05df0d1f0b2f..d2123fa71132 100644 --- a/core/src/raw/version.rs +++ b/core/src/raw/version.rs @@ -17,14 +17,3 @@ /// VERSION is the compiled version of OpenDAL. pub const VERSION: &str = env!("CARGO_PKG_VERSION"); - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_version() { - println!("opendal version: {VERSION}"); - assert!(!VERSION.is_empty()) - } -} diff --git a/core/src/services/aliyun_drive/core.rs b/core/src/services/aliyun_drive/core.rs index 1fe56657db8f..19351d681dd6 100644 --- a/core/src/services/aliyun_drive/core.rs +++ b/core/src/services/aliyun_drive/core.rs @@ -123,7 +123,7 @@ impl AliyunDriveCore { let mut tokener = self.signer.lock().await; if tokener.expire_at < Utc::now().timestamp() || tokener.access_token.is_none() { let res = self.get_access_token(&tokener.refresh_token).await?; - let output: RefresTokenResponse = + let output: RefreshTokenResponse = serde_json::from_reader(res.reader()).map_err(new_json_deserialize_error)?; tokener.access_token = Some(output.access_token); tokener.expire_at = output.expires_in + Utc::now().timestamp(); @@ -412,7 +412,7 @@ pub struct RapidUpload { } #[derive(Debug, Deserialize)] -pub struct RefresTokenResponse { +pub struct RefreshTokenResponse { pub access_token: String, pub expires_in: i64, pub refresh_token: String, @@ -420,9 +420,6 @@ pub struct RefresTokenResponse { #[derive(Debug, Deserialize)] pub struct DriveInfoResponse { - pub user_id: String, - pub name: String, - pub avatar: String, pub default_drive_id: String, pub resource_drive_id: Option, pub backup_drive_id: Option, @@ -444,22 +441,13 @@ pub enum CheckNameMode { #[derive(Deserialize)] pub struct UploadUrlResponse { - pub drive_id: String, - pub file_id: String, - pub upload_id: Option, pub part_info_list: Option>, } #[derive(Deserialize)] pub struct CreateResponse { - pub drive_id: String, pub file_id: String, - pub status: Option, - pub parent_file_id: String, pub upload_id: Option, - pub file_name: String, - pub available: Option, - pub exist: Option, pub rapid_upload: Option, pub part_info_list: Option>, } @@ -481,32 +469,24 @@ pub struct AliyunDriveFileList { #[derive(Deserialize)] pub struct CopyResponse { - pub drive_id: String, pub file_id: String, } #[derive(Deserialize)] pub struct AliyunDriveFile { - pub drive_id: String, pub file_id: String, pub parent_file_id: String, pub name: String, pub size: Option, - pub file_extension: Option, - pub content_hash: Option, pub content_type: Option, - pub category: Option, #[serde(rename = "type")] pub path_type: String, - pub created_at: String, pub updated_at: String, } #[derive(Deserialize)] pub struct GetDownloadUrlResponse { pub url: String, - pub expiration: String, - pub method: String, } #[derive(Serialize)] diff --git a/core/src/services/b2/core.rs b/core/src/services/b2/core.rs index 6aea7a6092b0..227a69e6d598 100644 --- a/core/src/services/b2/core.rs +++ b/core/src/services/b2/core.rs @@ -629,7 +629,6 @@ pub struct File { pub content_md5: Option, pub content_type: Option, pub file_name: String, - pub action: String, } pub(super) fn parse_file_info(file: &File) -> Metadata { diff --git a/core/src/services/chainsafe/core.rs b/core/src/services/chainsafe/core.rs index d4e4db179c55..c65617abd75e 100644 --- a/core/src/services/chainsafe/core.rs +++ b/core/src/services/chainsafe/core.rs @@ -247,11 +247,8 @@ impl ChainsafeCore { #[derive(Debug, Deserialize)] pub struct Info { pub name: String, - pub cid: String, pub content_type: String, pub size: u64, - pub version: i64, - pub created_at: i64, } #[derive(Deserialize)] diff --git a/core/src/services/d1/model.rs b/core/src/services/d1/model.rs index b4b0f25c8d69..d6bc7d8a8106 100644 --- a/core/src/services/d1/model.rs +++ b/core/src/services/d1/model.rs @@ -32,7 +32,6 @@ pub struct D1Response { pub result: Vec, pub success: bool, pub errors: Vec, - pub messages: Vec, } impl D1Response { @@ -77,21 +76,7 @@ impl D1Response { #[derive(Deserialize, Debug)] pub struct D1Result { - pub meta: Meta, pub results: Vec>, - pub success: bool, -} - -#[derive(Deserialize, Debug)] -pub struct Meta { - pub served_by: String, - pub duration: f64, - pub changes: i32, - pub last_row_id: i32, - pub changed_db: bool, - pub size_after: i32, - pub rows_read: i32, - pub rows_written: i32, } #[derive(Clone, Deserialize, Debug, Serialize)] @@ -100,12 +85,6 @@ pub struct D1Error { pub code: i32, } -#[derive(Deserialize, Debug)] -pub struct D1Message { - pub message: String, - pub code: i32, -} - #[cfg(test)] mod test { use super::*; diff --git a/core/src/services/icloud/core.rs b/core/src/services/icloud/core.rs index 5c4e44848f66..fa90e653aea3 100644 --- a/core/src/services/icloud/core.rs +++ b/core/src/services/icloud/core.rs @@ -623,16 +623,12 @@ pub struct Webservices { #[derive(Deserialize, Default, Clone, Debug)] #[serde(rename_all = "camelCase")] pub struct Drivews { - pub pcs_required: bool, - pub status: String, pub url: Option, } #[derive(Deserialize, Default, Clone, Debug)] #[serde(rename_all = "camelCase")] pub struct Docws { - pub pcs_required: bool, - pub status: String, pub url: Option, } diff --git a/core/src/services/oss/core.rs b/core/src/services/oss/core.rs index 229ef050d004..04b91ad74d3e 100644 --- a/core/src/services/oss/core.rs +++ b/core/src/services/oss/core.rs @@ -649,16 +649,6 @@ pub struct CompleteMultipartUploadRequest { pub part: Vec, } -#[derive(Default, Debug, Deserialize)] -#[serde(rename_all = "PascalCase")] -pub struct CompleteMultipartUploadResult { - pub location: String, - pub bucket: String, - pub key: String, - #[serde(rename = "ETag")] - pub etag: String, -} - #[derive(Default, Debug, Deserialize)] #[serde(default, rename_all = "PascalCase")] pub struct ListObjectsOutput { @@ -822,30 +812,6 @@ mod tests { ) } - #[test] - fn test_deserialize_complete_oss_multipart_result() { - let bytes = Bytes::from( - r#" - - url - http://oss-example.oss-cn-hangzhou.aliyuncs.com /multipart.data - oss-example - multipart.data - "B864DB6A936D376F9F8D3ED3BBE540****" -"#, - ); - - let result: CompleteMultipartUploadResult = - quick_xml::de::from_reader(bytes.reader()).unwrap(); - assert_eq!("\"B864DB6A936D376F9F8D3ED3BBE540****\"", result.etag); - assert_eq!( - "http://oss-example.oss-cn-hangzhou.aliyuncs.com /multipart.data", - result.location - ); - assert_eq!("oss-example", result.bucket); - assert_eq!("multipart.data", result.key); - } - #[test] fn test_parse_list_output() { let bs = bytes::Bytes::from( diff --git a/core/src/services/pcloud/core.rs b/core/src/services/pcloud/core.rs index 91c32b09ea15..0843626acdf7 100644 --- a/core/src/services/pcloud/core.rs +++ b/core/src/services/pcloud/core.rs @@ -413,11 +413,9 @@ pub struct StatResponse { #[derive(Debug, Deserialize)] pub struct StatMetadata { - pub name: String, pub modified: String, pub isfolder: bool, pub size: Option, - pub contenttype: Option, } #[derive(Debug, Deserialize)] @@ -428,11 +426,9 @@ pub struct ListFolderResponse { #[derive(Debug, Deserialize)] pub struct ListMetadata { - pub name: String, pub path: String, pub modified: String, pub isfolder: bool, pub size: Option, - pub contenttype: Option, pub contents: Option>, } diff --git a/core/src/services/swift/backend.rs b/core/src/services/swift/backend.rs index f5e9d51b6612..d784f305faf5 100644 --- a/core/src/services/swift/backend.rs +++ b/core/src/services/swift/backend.rs @@ -162,10 +162,7 @@ impl Builder for SwiftBuilder { }; debug!("backend use container: {}", &container); - let token = match self.token.take() { - Some(token) => token, - None => String::new(), - }; + let token = self.token.take().unwrap_or_default(); let client = HttpClient::new()?; diff --git a/core/src/services/yandex_disk/core.rs b/core/src/services/yandex_disk/core.rs index fb7b47058f34..76ad3f9f250a 100644 --- a/core/src/services/yandex_disk/core.rs +++ b/core/src/services/yandex_disk/core.rs @@ -289,7 +289,6 @@ pub struct GetUploadUrlResponse { pub struct MetainformationResponse { #[serde(rename = "type")] pub ty: String, - pub name: String, pub path: String, pub modified: String, pub md5: Option, diff --git a/core/tests/behavior/utils.rs b/core/tests/behavior/utils.rs index f877ae612a7c..17124e240608 100644 --- a/core/tests/behavior/utils.rs +++ b/core/tests/behavior/utils.rs @@ -17,7 +17,6 @@ use std::mem; use std::sync::Mutex; -use std::usize; use futures::Future; use libtest_mimic::Failed;