{"id":13562363,"url":"https://github.com/oxyno-zeta/gomock-extra-matcher","last_synced_at":"2025-04-13T21:43:12.350Z","repository":{"id":42155824,"uuid":"293288172","full_name":"oxyno-zeta/gomock-extra-matcher","owner":"oxyno-zeta","description":"Gomock Extra Matchers (Struct, Map, IntRange, StringRegexp)","archived":false,"fork":false,"pushed_at":"2025-02-02T01:03:44.000Z","size":104,"stargazers_count":18,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-27T12:07:32.766Z","etag":null,"topics":["gomock","gomock-matchers","matcher","mock","tests"],"latest_commit_sha":null,"homepage":"https://oxyno-zeta.github.io/gomock-extra-matcher/","language":"Go","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/oxyno-zeta.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","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":"2020-09-06T13:59:53.000Z","updated_at":"2024-10-30T03:44:04.000Z","dependencies_parsed_at":"2024-01-16T18:59:38.133Z","dependency_job_id":"bf44a49d-2c92-4c14-a813-dbf9685b345f","html_url":"https://github.com/oxyno-zeta/gomock-extra-matcher","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxyno-zeta%2Fgomock-extra-matcher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxyno-zeta%2Fgomock-extra-matcher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxyno-zeta%2Fgomock-extra-matcher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxyno-zeta%2Fgomock-extra-matcher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oxyno-zeta","download_url":"https://codeload.github.com/oxyno-zeta/gomock-extra-matcher/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248788867,"owners_count":21161726,"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":["gomock","gomock-matchers","matcher","mock","tests"],"created_at":"2024-08-01T13:01:07.787Z","updated_at":"2025-04-13T21:43:12.331Z","avatar_url":"https://github.com/oxyno-zeta.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003egomock-extra-matcher\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"http://godoc.org/github.com/oxyno-zeta/gomock-extra-matcher\" rel=\"noopener noreferer\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/badge/godoc-reference-blue.svg\" alt=\"Go Doc\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://circleci.com/gh/oxyno-zeta/gomock-extra-matcher\" rel=\"noopener noreferer\" target=\"_blank\"\u003e\u003cimg src=\"https://circleci.com/gh/oxyno-zeta/gomock-extra-matcher.svg?style=svg\" alt=\"CircleCI\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://goreportcard.com/report/github.com/oxyno-zeta/gomock-extra-matcher\" rel=\"noopener noreferer\" target=\"_blank\"\u003e\u003cimg src=\"https://goreportcard.com/badge/github.com/oxyno-zeta/gomock-extra-matcher\" alt=\"Go Report Card\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://coveralls.io/github/oxyno-zeta/gomock-extra-matcher?branch=master\" rel=\"noopener noreferer\" target=\"_blank\"\u003e\u003cimg src=\"https://coveralls.io/repos/github/oxyno-zeta/gomock-extra-matcher/badge.svg?branch=master\" alt=\"Coverage Status\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/oxyno-zeta/gomock-extra-matcher/blob/master/LICENSE\" rel=\"noopener noreferer\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/github/license/oxyno-zeta/gomock-extra-matcher\" alt=\"GitHub license\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/oxyno-zeta/gomock-extra-matcher/releases\" rel=\"noopener noreferer\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/github/v/release/oxyno-zeta/gomock-extra-matcher\" alt=\"GitHub release (latest by date)\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n---\n\n## Menu\n\n- [Menu](#menu)\n- [Why ?](#why-)\n- [How to use ?](#how-to-use-)\n- [Matchers](#matchers)\n  - [IntRangeMatcher](#intrangematcher)\n    - [Explanation](#explanation)\n    - [Example](#example)\n  - [StringRegexpMatcher](#stringregexpmatcher)\n    - [Explanation](#explanation-1)\n    - [Example](#example-1)\n  - [MapMatcher](#mapmatcher)\n    - [Explanation](#explanation-2)\n    - [Example](#example-2)\n  - [StructMatcher](#structmatcher)\n    - [Explanation](#explanation-3)\n    - [Example](#example-3)\n- [Thanks](#thanks)\n- [Author](#author)\n- [License](#license)\n\n## Why ?\n\nI've created this library because I cannot find such a library like this one and I don't want to create specific matcher for each structure, each map, ... in all tests that I have and can write.\n\nMoreover, creating specific matcher need maintenance code and this is time consumption.\n\nI'm sure that I'm not the only one that what to avoid all of this :) .\n\n## How to use ?\n\nImport the library in your tests files:\n\n```go\nimport \"github.com/oxyno-zeta/gomock-extra-matcher\"\n```\n\nUse it in your gomock instance:\n\n```go\nmock.EXPECT().DoSomething(extra.StringRegexpMatcher(`^[a-z]+\\[[0-9]+\\]$`))\n```\n\n## Matchers\n\n### IntRangeMatcher\n\n#### Explanation\n\nThis matcher will allow to test that an int is inside a range. Here it is considered that input can be equal to the lower bound and the same for the upper bound.\n\n#### Example\n\nHere is an example of usage:\n\n```go\nmock.EXPECT().DoSomething(extra.IntRangeMatcher(lowerBound, upperBound))\n```\n\n### StringRegexpMatcher\n\n#### Explanation\n\nThis matcher will allow to test that a string is validating a Regexp.\n\n#### Example\n\nHere is an example of usage:\n\n```go\nmock.EXPECT().DoSomething(extra.StringRegexpMatcher(`^[a-z]+\\[[0-9]+\\]$`))\n```\n\n### MapMatcher\n\n#### Explanation\n\nThis matcher will allow to test map key and map value.\n\nTo this one, it is possible to give a gomock matcher to a key and also to the value.\n\nThe `Key` function is chainable. It is also possible to more than one test per key.\n\n#### Example\n\nHere are some example of usage:\n\n```go\n// Here we consider a map[string]string as input\nmock.EXPECT().DoSomething(extra.MapMatcher().Key(\"key1\", \"value1\").Key(gomock.Any(), \"value1\").Key(\"key1\", gomock.Not(\"value2\")))\n```\n\n### StructMatcher\n\n#### Explanation\n\nThis matcher will allow to test public fields of a structure (Only public ones. Reflect can't manage private fields...).\n\nTo this matcher, it is possible to give either a gomock matcher or either a real value for validation.\n\nThe `Field` function is chainable. It is also possible to more than one test per field.\n\n#### Example\n\n```go\n// Here we consider a struct as this one\n/*\ntype Fake struct {\n    Name string\n    Data map[string]string\n}\n*/\nmock.EXPECT().DoSomething(extra.StructMatcher().Field(\"Name\", \"value1\").Field(\"Data\", gomock.Eq(map[string]string{\"fake\":\"value\"})))\n```\n\n### OrMatcher\n\n#### Explanation\n\nThis matcher will allow to test multiple matchers with a logical \"OR\" between them. This will stop at first match.\n\n#### Example\n\n```go\nmock.EXPECT().DoSomething(extra.OrMatcher(gomock.Eq(1), gomock.Eq(10), gomock.Eq(15)))\n```\n\n## Thanks\n\n- My wife BH to support me doing this\n\n## Author\n\n- Oxyno-zeta (Havrileck Alexandre)\n\n## License\n\nApache 2.0 (See in LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foxyno-zeta%2Fgomock-extra-matcher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foxyno-zeta%2Fgomock-extra-matcher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foxyno-zeta%2Fgomock-extra-matcher/lists"}