Add unit test for XML serialization and discover an issue
This commit is contained in:
parent
7c7268fc8a
commit
e9ba8f5e02
|
@ -540,8 +540,31 @@ impl CopyPreconditionHeaders {
|
|||
pub struct CopyPartResult {
|
||||
#[serde(serialize_with = "xmlns_tag")]
|
||||
pub xmlns: (),
|
||||
#[serde(rename = "ETag")]
|
||||
pub etag: s3_xml::Value,
|
||||
#[serde(rename = "LastModified")]
|
||||
pub last_modified: s3_xml::Value,
|
||||
#[serde(rename = "ETag")]
|
||||
pub etag: s3_xml::Value,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::s3_xml::to_xml_with_header;
|
||||
|
||||
#[test]
|
||||
fn serialize_copy_part_result() -> Result<(), Error> {
|
||||
// @FIXME: ETag should be quoted, but we can't add quotes
|
||||
// because XML serializer replaces them by `"`
|
||||
let expected_retval = r#"<?xml version="1.0" encoding="UTF-8"?><CopyPartResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><LastModified>2011-04-11T20:34:56.000Z</LastModified><ETag>9b2cf535f27731c974343645a3985328</ETag></CopyPartResult>"#;
|
||||
let v = CopyPartResult {
|
||||
xmlns: (),
|
||||
last_modified: s3_xml::Value("2011-04-11T20:34:56.000Z".into()),
|
||||
etag: s3_xml::Value("9b2cf535f27731c974343645a3985328".into()),
|
||||
};
|
||||
println!("{}", to_xml_with_header(&v)?);
|
||||
|
||||
assert_eq!(to_xml_with_header(&v)?, expected_retval);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -374,6 +374,8 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn copy_object_result() -> Result<(), ApiError> {
|
||||
// @FIXME: ETag should be quoted, but we can't add quotes
|
||||
// because XML serializer replaces them by `"`
|
||||
let copy_result = CopyObjectResult {
|
||||
last_modified: Value(msec_to_rfc3339(0)),
|
||||
etag: Value("9b2cf535f27731c974343645a3985328".to_string()),
|
||||
|
@ -412,6 +414,8 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn complete_multipart_upload_result() -> Result<(), ApiError> {
|
||||
// @FIXME: ETag should be quoted, but we can't add quotes
|
||||
// because XML serializer replaces them by `"`
|
||||
let result = CompleteMultipartUploadResult {
|
||||
xmlns: (),
|
||||
location: Some(Value("https://garage.tld/mybucket/a/plop".to_string())),
|
||||
|
@ -434,6 +438,8 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn list_objects_v1_1() -> Result<(), ApiError> {
|
||||
// @FIXME: ETag should be quoted, but we can't add quotes
|
||||
// because XML serializer replaces them by `"`
|
||||
let result = ListBucketResult {
|
||||
xmlns: (),
|
||||
name: Value("example-bucket".to_string()),
|
||||
|
@ -533,6 +539,8 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn list_objects_v2_1() -> Result<(), ApiError> {
|
||||
// @FIXME: ETag should be quoted, but we can't add quotes
|
||||
// because XML serializer replaces them by `"`
|
||||
let result = ListBucketResult {
|
||||
xmlns: (),
|
||||
name: Value("quotes".to_string()),
|
||||
|
@ -579,6 +587,8 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn list_objects_v2_2() -> Result<(), ApiError> {
|
||||
// @FIXME: ETag should be quoted, but we can't add quotes
|
||||
// because XML serializer replaces them by `"`
|
||||
let result = ListBucketResult {
|
||||
xmlns: (),
|
||||
name: Value("bucket".to_string()),
|
||||
|
|
Loading…
Reference in a new issue