{"id":17183390,"url":"https://github.com/geod24/localrest","last_synced_at":"2026-02-06T13:39:34.665Z","repository":{"id":34023901,"uuid":"165793169","full_name":"Geod24/localrest","owner":"Geod24","description":"A library to allow integration testing of vibe.web.rest based code","archived":false,"fork":false,"pushed_at":"2025-01-24T15:45:04.000Z","size":247,"stargazers_count":4,"open_issues_count":5,"forks_count":8,"subscribers_count":2,"default_branch":"v0.x.x","last_synced_at":"2025-03-25T02:40:37.640Z","etag":null,"topics":["concurrency","dlang","eventloop","hacktoberfest","testing","unittests"],"latest_commit_sha":null,"homepage":"","language":"D","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Geod24.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}},"created_at":"2019-01-15T05:51:09.000Z","updated_at":"2025-01-24T15:45:04.000Z","dependencies_parsed_at":"2025-01-24T16:31:49.861Z","dependency_job_id":null,"html_url":"https://github.com/Geod24/localrest","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/Geod24/localrest","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Geod24%2Flocalrest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Geod24%2Flocalrest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Geod24%2Flocalrest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Geod24%2Flocalrest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Geod24","download_url":"https://codeload.github.com/Geod24/localrest/tar.gz/refs/heads/v0.x.x","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Geod24%2Flocalrest/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266608969,"owners_count":23955545,"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","status":"online","status_checked_at":"2025-07-23T02:00:09.312Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["concurrency","dlang","eventloop","hacktoberfest","testing","unittests"],"created_at":"2024-10-15T00:40:27.301Z","updated_at":"2026-02-06T13:39:34.636Z","avatar_url":"https://github.com/Geod24.png","language":"D","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LocalRest\n\n[![DUB Package](https://img.shields.io/dub/v/localrest.svg)](https://code.dlang.org/packages/localrest)\n[![codecov](https://codecov.io/gh/Geod24/localrest/branch/v0.x.x/graph/badge.svg)](https://codecov.io/gh/Geod24/localrest)\n\nA library to allow integration testing of `vibe.web.rest` based code as unittests.\n\n## Example\n\nThe [main source file](source/geod24/LocalRest.d) is extensively documented, and includes many unittests.\n\nThe straightforward approach is to do:\n```D\n    static interface API\n    {\n        @safe: // Vibe.d requirement, but LocalRest works with `@system`\n        public @property ulong pubkey ();\n        public string getValue (ulong idx);\n        public ubyte[32] getQuorumSet ();\n        public string recv (string data);\n    }\n\n    static class MockAPI : API\n    {\n        @safe:\n        public override @property ulong pubkey ()\n        { return 42; }\n        public override string getValue (ulong idx)\n        { assert(0); }\n        public override ubyte[32] getQuorumSet ()\n        { assert(0); }\n        public override string recv (string data)\n        { assert(0); }\n    }\n\n    // This will start a new thread, create a `MockAPI` object in it,\n    // and return a handle that allows communicating with it.\n    scope API test = RemoteAPI!API.spawn!MockAPI();\n    // Note that the handle will be of type `RemoteAPI!API`, which implements `API`\n    // This is so one can have an array of `API`, but different underlying implementations.\n\n    // This will send a message to the remote thread, which will ultimately call `MockAPI.pubkey`\n    // Any parameter and return value is serialized to a type that is safe to pass accross thread.\n    // By default, Vibe.d's JSON serializer is used, but it can be replaced (see `geod24.Serialization`).\n    assert(test.pubkey() == 42);\n\n    // Remote nodes can be controlled, to extend testing parameters:\n    // For example, they can be made to be unresponsive for a set duration,\n    // or to ignore calls to certain methods.\n    test.ctrl.shutdown();\n```\n\nFor this to work, one need to have Vibe.d already fetched. For a simple test, `dub fetch vibe-d` will suffice.\nFor project depending on this, make sure your `dub.json` includes the following in `dependencies`:\n```json\n{\n    \"vibe-d:data\": \"~\u003e0.8\"\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeod24%2Flocalrest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgeod24%2Flocalrest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeod24%2Flocalrest/lists"}