{"id":29536649,"url":"https://github.com/IBM/mocktail","last_synced_at":"2025-07-17T03:04:09.951Z","repository":{"id":271603804,"uuid":"912968677","full_name":"IBM/mocktail","owner":"IBM","description":"HTTP \u0026 gRPC server mocking for Rust, with native support for streaming","archived":false,"fork":false,"pushed_at":"2025-07-11T20:02:52.000Z","size":159,"stargazers_count":71,"open_issues_count":3,"forks_count":7,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-07-11T20:23:03.603Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://ibm.github.io/mocktail/","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/IBM.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null}},"created_at":"2025-01-06T19:03:02.000Z","updated_at":"2025-07-11T19:40:13.000Z","dependencies_parsed_at":"2025-01-08T19:29:38.244Z","dependency_job_id":"fd99a537-cfd0-44f6-9a50-2b5ad7230b23","html_url":"https://github.com/IBM/mocktail","commit_stats":null,"previous_names":["ibm/mocktail"],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/IBM/mocktail","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IBM%2Fmocktail","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IBM%2Fmocktail/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IBM%2Fmocktail/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IBM%2Fmocktail/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/IBM","download_url":"https://codeload.github.com/IBM/mocktail/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IBM%2Fmocktail/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265561988,"owners_count":23788446,"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":"2025-07-17T03:02:02.127Z","updated_at":"2025-07-17T03:04:09.946Z","avatar_url":"https://github.com/IBM.png","language":"Rust","readme":"![default-monochrome](https://github.com/user-attachments/assets/dcf68c3e-4c16-4a96-a6d3-2af4710692c6)\n\nmocktail is a **minimal** crate for mocking HTTP and gRPC servers in Rust, with native support for streaming.\n\n[![Crates.io](https://img.shields.io/crates/v/mocktail)](https://crates.io/crates/mocktail)\n[![Documentation](https://docs.rs/mocktail/badge.svg)](https://docs.rs/mocktail)\n[![Book](https://img.shields.io/static/v1?label=mocktail\u0026message=user-guide\u0026color=153292)](https://ibm.github.io/mocktail/)\n[![Crates.io](https://img.shields.io/crates/l/mocktail)](LICENSE)\n\n\n# Table of contents\n* [Features](#features)\n* [Getting Started](#getting-started)\n* [Examples](#examples)\n\n# Features\n- Mocks HTTP and gRPC servers\n- Mocks defined in Rust using a simple, ergonomic API\n- Provides first-class support for streaming\n- Supports gRPC unary, client-streaming, server-streaming, and bidirectional-streaming methods\n- Match requests to mock responses using built-in matchers or custom matchers\n- Fully asynchronous\n\n# Getting Started\n1. Add `mocktail` to `Cargo.toml` as a development dependency:\n    ```toml\n    [dev-dependencies]\n    mocktail = \"0.3.0\"\n    ```\n\n2. Basic usage example:\n    ```rust\n    use mocktail::prelude::*;\n\n    #[tokio::test]\n    async fn test_example() -\u003e Result\u003c(), Box\u003cdyn std::error::Error\u003e\u003e {\n        // Create a mock set\n        let mut mocks = MockSet::new();\n\n        // Build a mock that returns a \"hello world!\" response\n        // to POST requests to the /hello endpoint with the text \"world\"\n        // in the body.\n        mocks.mock(|when, then| {\n            when.post().path(\"/hello\").text(\"world\");\n            then.text(\"hello world!\");\n        });\n\n        // Create and start a mock server\n        let mut server = MockServer::new_http(\"example\").with_mocks(mocks);\n        server.start().await?;\n\n        // Create a client\n        let client = reqwest::Client::builder().http2_prior_knowledge().build()?;\n\n        // Send a request that matches the mock created above\n        let response = client\n            .post(server.url(\"/hello\"))\n            .body(\"world\")\n            .send()\n            .await?;\n        assert_eq!(response.status(), http::StatusCode::OK);\n        let body = response.text().await?;\n        assert_eq!(body, \"hello world!\");\n\n        // Send a request that doesn't match a mock\n        let response = client.get(server.url(\"/nope\")).send().await?;\n        assert_eq!(response.status(), http::StatusCode::NOT_FOUND);\n\n        // Mocks can also be registered to the server directly\n        // Register a mock that will match the request above that returned 404\n        server.mock(|when, then| {\n            when.get().path(\"/nope\");\n            then.text(\"yep!\");\n        });\n\n        // Send the request again, it should now match\n        let response = client.get(server.url(\"/nope\")).send().await?;\n        assert_eq!(response.status(), http::StatusCode::OK);\n        let body = response.text().await?;\n        assert_eq!(body, \"yep!\");\n\n        // Mocks can be cleared from the server, enabling server reuse\n        server.mocks.clear();\n\n        Ok(())\n    }\n    ```\n\n3. See the [book](https://ibm.github.io/mocktail/) and [examples](/mocktail-tests/tests/examples) in the `mocktail-tests` crate.\n\n# Examples\nSee [examples](/mocktail-tests/tests/examples) in the `mocktail-tests` crate.\n\n# Related projects\nThis crate takes inspiration from other great mocking libraries including:\n- [wiremock](https://github.com/wiremock/wiremock)\n- [wiremock-rs](https://github.com/LukeMathWalker/wiremock-rs)\n- [httpmock](https://github.com/alexliesenfeld/httpmock)\n","funding_links":[],"categories":["Development tools"],"sub_categories":["Testing"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FIBM%2Fmocktail","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FIBM%2Fmocktail","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FIBM%2Fmocktail/lists"}