Fix #[serde(flatten)] annotation and add ResourceType value (#1436)

This commit is contained in:
CHarrod283 2023-10-09 07:39:38 -05:00 коммит произвёл GitHub
Родитель 20c1d7859d
Коммит f290339742
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 45 добавлений и 1 удалений

Просмотреть файл

@ -26,6 +26,7 @@ use azure_core::{
};
use azure_storage::{ConsistencyCRC64, ConsistencyMD5, CopyId, CopyProgress};
use serde::{self, Deserialize, Deserializer};
use serde_json::Value;
use std::collections::HashMap;
use time::OffsetDateTime;
@ -174,8 +175,9 @@ pub struct BlobProperties {
)]
pub expiry_time: Option<OffsetDateTime>,
pub blob_committed_block_count: Option<u64>,
pub resource_type: Option<String>,
#[serde(flatten)]
extra: HashMap<String, String>, // For debug purposes, should be compiled out in the future
extra: HashMap<String, Value>, // For debug purposes, should be compiled out in the future
}
impl Blob {
@ -281,6 +283,7 @@ impl Blob {
tag_count: None, // TODO
rehydrate_priority: None, // TODO
expiry_time: None,
resource_type: None,
blob_committed_block_count,
extra: HashMap::new(),
},

Просмотреть файл

@ -338,6 +338,47 @@ mod tests {
let _list_blobs_response_internal: ListBlobsResponseInternal = read_xml(&bytes).unwrap();
}
#[test]
fn deserde_properties_with_non_existent_field() {
const XML: &str = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>
<EnumerationResults ServiceEndpoint=\"http://127.0.0.1:10000/devstoreaccount1\" ContainerName=\"temp\">
<Prefix>b39bc5c9-0f31-459c-a271-828467105470/</Prefix>
<Marker/>
<MaxResults>5000</MaxResults>
<Delimiter/>
<Blobs>
<Blob>
<Name>b39bc5c9-0f31-459c-a271-828467105470/corrupted_data_2020-01-02T03_04_05.json</Name>
<Properties>
<Creation-Time>Mon, 02 Oct 2023 20:00:31 GMT</Creation-Time>
<Last-Modified>Mon, 02 Oct 2023 20:00:31 GMT</Last-Modified>
<Etag>0x23D9DB658CF7480</Etag>
<Content-Length>0</Content-Length>
<Content-Type>application/octet-stream</Content-Type>
<Content-Encoding/>
<Content-Language/>
<Content-CRC64/>
<Content-MD5/>
<Cache-Control/>
<Content-Disposition/>
<BlobType>BlockBlob</BlobType>
<AccessTier>Hot</AccessTier>
<AccessTierInferred>true</AccessTierInferred>
<LeaseStatus>unlocked</LeaseStatus>
<LeaseState>available</LeaseState>
<ServerEncrypted>true</ServerEncrypted>
<ResourceType>file</ResourceType>
<NotRealProperty>notRealValue</NotRealProperty>
</Properties>
</Blob>
</Blobs>
<NextMarker/>
</EnumerationResults>";
let bytes = Bytes::from(XML);
let _list_blobs_response_internal: ListBlobsResponseInternal = read_xml(&bytes).unwrap();
}
#[test]
fn deserde_azurite_without_server_encrypted() {
const S: &str = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>