{"id":16115511,"url":"https://github.com/byron/yup-hyper-mock","last_synced_at":"2025-05-12T03:31:49.688Z","repository":{"id":27889536,"uuid":"31381008","full_name":"Byron/yup-hyper-mock","owner":"Byron","description":"`hyper-mock` is a utility library to help hyper clients with their testing","archived":false,"fork":false,"pushed_at":"2024-01-15T18:36:59.000Z","size":4836,"stargazers_count":29,"open_issues_count":0,"forks_count":14,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-17T22:49:27.586Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://docs.rs/yup-hyper-mock","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Byron.png","metadata":{"files":{"readme":"README.md","changelog":"changelog.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-02-26T18:07:57.000Z","updated_at":"2024-01-15T18:45:46.000Z","dependencies_parsed_at":"2024-06-21T07:11:11.082Z","dependency_job_id":"83f95b25-af14-42ca-98f8-4c07420779a6","html_url":"https://github.com/Byron/yup-hyper-mock","commit_stats":{"total_commits":80,"total_committers":16,"mean_commits":5.0,"dds":"0.44999999999999996","last_synced_commit":"7cf5c37bf958808b5579b9e2f3e2150bffc26424"},"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Byron%2Fyup-hyper-mock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Byron%2Fyup-hyper-mock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Byron%2Fyup-hyper-mock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Byron%2Fyup-hyper-mock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Byron","download_url":"https://codeload.github.com/Byron/yup-hyper-mock/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253668066,"owners_count":21944971,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-09T20:19:02.059Z","updated_at":"2025-05-12T03:31:49.406Z","avatar_url":"https://github.com/Byron.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Rust](https://github.com/Byron/yup-hyper-mock/workflows/Rust/badge.svg)](https://github.com/Byron/yup-hyper-mock/actions)\n[![Crates.io](https://img.shields.io/crates/v/yup-hyper-mock.svg)](https://crates.io/crates/yup-hyper-mock)\n\n`hyper-mock` is a utility library to help hyper clients with their testing. It provides types used to test hyper itself, most notably, mock connections and macros to ease their use.\n\n## Usage\n\nSet it up for use in tests in `Cargo.toml`\n```toml\n[dev-dependencies]\nyup-hyper-mock = \"*\"\nlog = \"*\"  # log macros are used within yup-hyper-mock\n```\n\nIn your tests module\n```Rust\n#[cfg(test)]\nmod tests {\n    use hyper;\n    use hyper_util::client::legacy::Client;\n\n    yup_hyper_mock::mock_connector!(MockRedirectPolicy {\n        \"http://127.0.0.1\" =\u003e       \"HTTP/1.1 301 Redirect\\r\\n\\\n                                     Location: http://127.0.0.2\\r\\n\\\n                                     Server: mock1\\r\\n\\\n                                     \\r\\n\\\n                                    \"\n        \"http://127.0.0.2\" =\u003e       \"HTTP/1.1 302 Found\\r\\n\\\n                                     Location: https://127.0.0.3\\r\\n\\\n                                     Server: mock2\\r\\n\\\n                                     \\r\\n\\\n                                    \"\n        \"https://127.0.0.3\" =\u003e      \"HTTP/1.1 200 OK\\r\\n\\\n                                     Server: mock3\\r\\n\\\n                                     \\r\\n\\\n                                    \"\n    });\n\n    #[tokio::test]\n    async fn test_redirect_followall() {\n        let builder =\n            hyper_util::client::legacy::Client::builder(hyper_util::rt::TokioExecutor::new());\n        let client: Client\u003cMockRedirectPolicy, http_body_util::Empty\u003chyper::body::Bytes\u003e\u003e =\n            builder.build(MockRedirectPolicy::default());\n\n        let res = client\n            .get(hyper::Uri::from_static(\"http://127.0.0.1\"))\n            .await\n            .unwrap();\n\n        let headers = res.headers();\n        assert!(headers.contains_key(\"Server\"));\n        assert_eq!(headers[\"Server\"], \"mock1\");\n    }\n}\n```\n\n## Credits\n\n`yup-hyper-mock` is code from `hyper/src/mock.rs`, which was adjusted to work within its very own crate.\n\n\n## License\n\nLicensed under either of\n * Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)\n * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)\nat your option.\n\n### Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in the work by you shall be dual licensed as above, without any\nadditional terms or conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbyron%2Fyup-hyper-mock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbyron%2Fyup-hyper-mock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbyron%2Fyup-hyper-mock/lists"}