fn test_multipart_mixed_gcs_batch_metadata_response()

in core/src/raw/http_util/multipart.rs [836:1018]


    fn test_multipart_mixed_gcs_batch_metadata_response() {
        let response = r#"--batch_pK7JBAk73-E=_AA5eFwv4m2Q=
Content-Type: application/http
Content-ID: <response-b29c5de2-0db4-490b-b421-6a51b598bd22+1>

HTTP/1.1 200 OK
ETag: "lGaP-E0memYDumK16YuUDM_6Gf0/V43j6azD55CPRGb9b6uytDYl61Y"
Content-Type: application/json; charset=UTF-8
Date: Mon, 22 Jan 2018 18:56:00 GMT
Expires: Mon, 22 Jan 2018 18:56:00 GMT
Cache-Control: private, max-age=0
Content-Length: 846

{"kind": "storage#object","id": "example-bucket/obj1/1495822576643790","metadata": {"type": "tabby"}}

--batch_pK7JBAk73-E=_AA5eFwv4m2Q=
Content-Type: application/http
Content-ID: <response-b29c5de2-0db4-490b-b421-6a51b598bd22+2>

HTTP/1.1 200 OK
ETag: "lGaP-E0memYDumK16YuUDM_6Gf0/91POdd-sxSAkJnS8Dm7wMxBSDKk"
Content-Type: application/json; charset=UTF-8
Date: Mon, 22 Jan 2018 18:56:00 GMT
Expires: Mon, 22 Jan 2018 18:56:00 GMT
Cache-Control: private, max-age=0
Content-Length: 846

{"kind": "storage#object","id": "example-bucket/obj2/1495822576643790","metadata": {"type": "tuxedo"}}

--batch_pK7JBAk73-E=_AA5eFwv4m2Q=
Content-Type: application/http
Content-ID: <response-b29c5de2-0db4-490b-b421-6a51b598bd22+3>

HTTP/1.1 200 OK
ETag: "lGaP-E0memYDumK16YuUDM_6Gf0/d2Z1F1_ZVbB1dC0YKM9rX5VAgIQ"
Content-Type: application/json; charset=UTF-8
Date: Mon, 22 Jan 2018 18:56:00 GMT
Expires: Mon, 22 Jan 2018 18:56:00 GMT
Cache-Control: private, max-age=0
Content-Length: 846

{"kind": "storage#object","id": "example-bucket/obj3/1495822576643790","metadata": {"type": "calico"}}

--batch_pK7JBAk73-E=_AA5eFwv4m2Q=--"#.replace('\n', "\r\n");

        let multipart: Multipart<MixedPart> = Multipart::new()
            .with_boundary("batch_pK7JBAk73-E=_AA5eFwv4m2Q=")
            .parse(Bytes::from(response))
            .unwrap();

        assert_eq!(multipart.parts.len(), 3);
        assert_eq!(
            multipart.parts[0],
            MixedPart {
                part_headers: {
                    let mut h = HeaderMap::new();
                    h.insert("Content-Type", "application/http".parse().unwrap());
                    h.insert(
                        "Content-ID",
                        "<response-b29c5de2-0db4-490b-b421-6a51b598bd22+1>"
                            .parse()
                            .unwrap(),
                    );

                    h
                },
                version: Version::HTTP_11,
                headers: {
                    let mut h = HeaderMap::new();
                    h.insert(
                        "ETag",
                        "\"lGaP-E0memYDumK16YuUDM_6Gf0/V43j6azD55CPRGb9b6uytDYl61Y\""
                            .parse()
                            .unwrap(),
                    );
                    h.insert(
                        "Content-Type",
                        "application/json; charset=UTF-8".parse().unwrap(),
                    );
                    h.insert("Date", "Mon, 22 Jan 2018 18:56:00 GMT".parse().unwrap());
                    h.insert("Expires", "Mon, 22 Jan 2018 18:56:00 GMT".parse().unwrap());
                    h.insert("Cache-Control", "private, max-age=0".parse().unwrap());
                    h.insert("Content-Length", "846".parse().unwrap());

                    h
                },
                content: Bytes::from_static(
                    r#"{"kind": "storage#object","id": "example-bucket/obj1/1495822576643790","metadata": {"type": "tabby"}}"#
                    .as_bytes()
                ),
                uri: None,
                method: None,
                status_code: Some(StatusCode::from_u16(200).unwrap())
            }
        );
        assert_eq!(
            multipart.parts[1],
            MixedPart {
                part_headers: {
                    let mut h = HeaderMap::new();
                    h.insert("Content-Type", "application/http".parse().unwrap());
                    h.insert(
                        "Content-ID",
                        "<response-b29c5de2-0db4-490b-b421-6a51b598bd22+2>"
                            .parse()
                            .unwrap(),
                    );

                    h
                },
                version: Version::HTTP_11,
                headers: {
                    let mut h = HeaderMap::new();
                    h.insert(
                        "ETag",
                        "\"lGaP-E0memYDumK16YuUDM_6Gf0/91POdd-sxSAkJnS8Dm7wMxBSDKk\""
                            .parse()
                            .unwrap(),
                    );
                    h.insert(
                        "Content-Type",
                        "application/json; charset=UTF-8".parse().unwrap(),
                    );
                    h.insert("Date", "Mon, 22 Jan 2018 18:56:00 GMT".parse().unwrap());
                    h.insert("Expires", "Mon, 22 Jan 2018 18:56:00 GMT".parse().unwrap());
                    h.insert("Cache-Control", "private, max-age=0".parse().unwrap());
                    h.insert("Content-Length", "846".parse().unwrap());

                    h
                },
                content: Bytes::from_static(
                    r#"{"kind": "storage#object","id": "example-bucket/obj2/1495822576643790","metadata": {"type": "tuxedo"}}"#
                    .as_bytes()
                ),
                uri: None,
                method: None,
                status_code: Some(StatusCode::from_u16(200).unwrap())
            }
         );
        assert_eq!(
            multipart.parts[2],
            MixedPart {
                part_headers: {
                    let mut h = HeaderMap::new();
                    h.insert("Content-Type", "application/http".parse().unwrap());
                    h.insert(
                        "Content-ID",
                        "<response-b29c5de2-0db4-490b-b421-6a51b598bd22+3>"
                            .parse()
                            .unwrap(),
                    );

                    h
                },
                version: Version::HTTP_11,
                headers: {
                    let mut h = HeaderMap::new();
                    h.insert(
                        "ETag",
                        "\"lGaP-E0memYDumK16YuUDM_6Gf0/d2Z1F1_ZVbB1dC0YKM9rX5VAgIQ\""
                            .parse()
                            .unwrap(),
                    );
                    h.insert(
                        "Content-Type",
                        "application/json; charset=UTF-8".parse().unwrap(),
                    );
                    h.insert("Date", "Mon, 22 Jan 2018 18:56:00 GMT".parse().unwrap());
                    h.insert("Expires", "Mon, 22 Jan 2018 18:56:00 GMT".parse().unwrap());
                    h.insert("Cache-Control", "private, max-age=0".parse().unwrap());
                    h.insert("Content-Length", "846".parse().unwrap());

                    h
                },
                content: Bytes::from_static(
                    r#"{"kind": "storage#object","id": "example-bucket/obj3/1495822576643790","metadata": {"type": "calico"}}"#
                    .as_bytes()
                ),
                uri: None,
                method: None,
                status_code: Some(StatusCode::from_u16(200).unwrap())
            });
    }