{"id":24200095,"url":"https://github.com/lesiw/moxie","last_synced_at":"2025-09-21T23:32:28.365Z","repository":{"id":251125701,"uuid":"836468743","full_name":"lesiw/moxie","owner":"lesiw","description":"Go mock library that proxies method calls to embedded types.","archived":false,"fork":false,"pushed_at":"2024-08-13T23:20:50.000Z","size":59,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-15T00:57:58.861Z","etag":null,"topics":["code-generation","go","go-test","go-testing","golang","mock","test-tools","testing"],"latest_commit_sha":null,"homepage":"https://lesiw.io/moxie","language":"Go","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/lesiw.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":"2024-07-31T23:23:37.000Z","updated_at":"2024-08-15T17:01:13.000Z","dependencies_parsed_at":"2024-08-04T22:05:29.396Z","dependency_job_id":"185e1855-892c-46cc-9053-4273f1512539","html_url":"https://github.com/lesiw/moxie","commit_stats":null,"previous_names":["lesiw/moxie"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lesiw%2Fmoxie","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lesiw%2Fmoxie/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lesiw%2Fmoxie/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lesiw%2Fmoxie/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lesiw","download_url":"https://codeload.github.com/lesiw/moxie/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":233808156,"owners_count":18733527,"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":["code-generation","go","go-test","go-testing","golang","mock","test-tools","testing"],"created_at":"2025-01-13T20:41:04.265Z","updated_at":"2025-09-21T23:32:28.357Z","avatar_url":"https://github.com/lesiw.png","language":"Go","readme":"# lesiw.io/moxie: Generate mocks with proxy functions\n\nGo has a convenient feature called [embedding][embedding]. Method calls are\ntransparently passed through to embedded types.\n\n`moxie` generates proxy methods that are only added during `go test`.\n\n## Usage\n\nAdd this line to your code, where `T` is the type you want to instrument, and\n`E` is the embedded type whose functions you want to intercept.\n\n``` go\n//go:generate go run lesiw.io/moxie@latest T\ntype T struct {\n    E\n}\n```\n\nThen run `go generate`.\n\n## Functions\n\n`moxie` makes the following methods on `T` available at test time.\n\n### Instance methods\n\n```go\n(*T)._Func_Stub()      // when called, return zero values.\n(*T)._Func_Return(...) // when called, return these values.\n\n(*T)._Func_Do(func() {...}) // when called, run this instead.\n                            // calling this with nil will un-mock the function.\n\n(*T)._Func_Calls() []_T_Func_Call // return calls to Func.\n```\n\nMocks queue. For example, mocking with `(*T)._Func_Return` twice will return the\nfirst set of values the next time the function is called, then return the second\nset of values in subsequent calls.\n\n### Global methods\n\n```go\nnew(T)._Func_StubAll(*testing.T)         // when called, return zero values.\nnew(T)._Func_ReturnAll(*testing.T, ...)  // when called, return these values.\n\nnew(T)._Func_DoAll(*testing.T, func() {...}) // when called, run this instead.\n                                             // calling this with nil\n                                             // will un-mock the function.\n\nnew(T)._Func_AllCalls() []_T_Func_Call // return calls to Func.\nnew(T)._Func_BubbleCalls(*testing.T)   // clear calls before and after test.\n```\n\nAs above, mocks queue.\n\nThese methods may be easier to use in some cases, as they operate on _all_ `T`\ntypes. This can be helpful in situations where injecting a mock value into the\ncode under test may be difficult to do. Note, however, that this makes them\nunsafe for use with `t.Parallel()`.\n\nMethods that accept a `*testing.T` will clean up mocks at the end of their\ncorresponding test or subtest.\n\nTests using `AllCalls()` should also call `new(T)._Func_BubbleCalls(t)`,\notherwise `AllCalls()` may also contain calls from other tests. \n\n[embedding]: https://go.dev/doc/effective_go#embedding\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flesiw%2Fmoxie","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flesiw%2Fmoxie","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flesiw%2Fmoxie/lists"}