{"id":18818647,"url":"https://github.com/ibokuri/protest","last_synced_at":"2025-03-30T01:18:54.412Z","repository":{"id":209369445,"uuid":"720638937","full_name":"ibokuri/protest","owner":"ibokuri","description":"A set of modules for easy testing in Zig","archived":false,"fork":false,"pushed_at":"2024-06-12T14:05:23.000Z","size":25547,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-05T03:17:29.184Z","etag":null,"topics":["assert","assertions","require","testing","zig","ziglang"],"latest_commit_sha":null,"homepage":"https://ibokuri.github.io/protest/","language":"Zig","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/ibokuri.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":"2023-11-19T05:11:52.000Z","updated_at":"2024-06-12T14:04:41.000Z","dependencies_parsed_at":"2024-04-21T21:54:31.382Z","dependency_job_id":null,"html_url":"https://github.com/ibokuri/protest","commit_stats":{"total_commits":75,"total_committers":1,"mean_commits":75.0,"dds":0.0,"last_synced_commit":"bae398b701e763ef18480aa3cfcca103716996de"},"previous_names":["ibokuri/protest"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ibokuri%2Fprotest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ibokuri%2Fprotest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ibokuri%2Fprotest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ibokuri%2Fprotest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ibokuri","download_url":"https://codeload.github.com/ibokuri/protest/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246262610,"owners_count":20749176,"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":["assert","assertions","require","testing","zig","ziglang"],"created_at":"2024-11-08T00:17:35.041Z","updated_at":"2025-03-30T01:18:54.396Z","avatar_url":"https://github.com/ibokuri.png","language":"Zig","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Protest\n\n\u003ca href=\"https://github.com/ibokuri/protest/releases/latest\"\u003e\u003cimg alt=\"Version\" src=\"https://img.shields.io/github/v/release/ibokuri/protest?include_prereleases\u0026label=version\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/ibokuri/protest/actions/workflows/test.yml\"\u003e\u003cimg alt=\"Build status\" src=\"https://img.shields.io/github/actions/workflow/status/ibokuri/protest/test.yml?branch=main\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://ziglang.org/download\"\u003e\u003cimg alt=\"Zig\" src=\"https://img.shields.io/badge/zig-master-fd9930.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/ibokuri/protest/blob/main/LICENSE\"\u003e\u003cimg alt=\"License\" src=\"https://img.shields.io/badge/license-MIT-blue\"\u003e\u003c/a\u003e\n\nProtest is a set of modules for testing and validating Zig code. A\n[testify](https://github.com/stretchr/testify) for Zig, if you will, cause testify's awesome!\n\n## [`require`](https://ibokuri.github.io/protest/#A;protest:require) Module\n\nThe `require` module some provides helpful functions to help you write tests.\n\n- Descriptive and easy to read failure descriptions.\n- Simplified testing code.\n- Requirements can be annotated with a custom message.\n\n```zig\nconst require = @import(\"protest\").require;\n\ntest {\n    // Require equality.\n    try require.equalf(123, 123, \"They should be {s}\", .{\"equal\"});\n\n    // Require inequality.\n    try require.notEqualf(123, 456, \"They should not be {s}\", .{\"equal\"});\n\n    // Require that `value` is not null.\n    try require.notNull(value);\n\n    // Since `value` cannot be null, safely unwrap it and check its payload.\n    try require.equal(\"Foobar\", value.?);\n}\n```\n\n```\nrun test: error: 'test_0' failed:\n\n        Error:          Not equal:\n                        expected: \"Foobar\"\n                        actual:   \"Barfoo\"\n        Error Trace:\n\n/tmp/example/src/main.zig:14:5: 0x1048a5027 in test_0 (test)\n    try require.equal(\"Foobar\", value.?);\n    ^\n```\n\n## Installation\n\n1. Declare Protest as a dependency in `build.zig.zon`:\n\n    ```diff\n    .{\n        .name = \"my-project\",\n        .version = \"1.0.0\",\n        .paths = .{\"\"},\n        .dependencies = .{\n    +       .protest = .{\n    +           .url = \"https://github.com/ibokuri/protest/archive/\u003cCOMMIT\u003e.tar.gz\",\n    +       },\n        },\n    }\n    ```\n\n2. Add Protest as a module in `build.zig`:\n\n    ```diff\n    const std = @import(\"std\");\n\n    pub fn build(b: *std.Build) void {\n        const target = b.standardTargetOptions(.{});\n        const optimize = b.standardOptimizeOption(.{});\n\n    +   const opts = .{ .target = target, .optimize = optimize };\n    +   const protest_mod = b.dependency(\"protest\", opts).module(\"protest\");\n\n        const tests = b.addTest(.{\n            .root_source_file = .{ .path = \"src/main.zig\" },\n            .target = target,\n            .optimize = optimize,\n        });\n\n    +   tests.addModule(\"protest\", protest_mod);\n\n        ...\n    }\n    ```\n\n3. Obtain Protest's package hash:\n\n    ```\n    $ zig build --fetch\n    my-project/build.zig.zon:7:20: error: url field is missing corresponding hash field\n            .url = \"https://github.com/ibokuri/protest/archive/\u003cCOMMIT\u003e.tar.gz\",\n                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n    note: expected .hash = \"\u003cHASH\u003e\",\n    ```\n\n4. Update `build.zig.zon` with Protest's package hash:\n\n    ```diff\n    .{\n        .name = \"my-project\",\n        .version = \"1.0.0\",\n        .paths = .{\"\"},\n        .dependencies = .{\n            .protest = .{\n                .url = \"https://github.com/ibokuri/protest/archive/\u003cCOMMIT\u003e.tar.gz\",\n    +           .hash = \"\u003cHASH\u003e\",\n            },\n        },\n    }\n    ```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fibokuri%2Fprotest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fibokuri%2Fprotest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fibokuri%2Fprotest/lists"}