{"id":15645783,"url":"https://github.com/code-hex/funcy-mock","last_synced_at":"2025-04-30T10:47:20.221Z","repository":{"id":57508733,"uuid":"134555344","full_name":"Code-Hex/funcy-mock","owner":"Code-Hex","description":"funcy-mock generates mock file from interface go file","archived":false,"fork":false,"pushed_at":"2018-08-30T17:49:40.000Z","size":21,"stargazers_count":52,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-30T10:47:11.079Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/Code-Hex.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}},"created_at":"2018-05-23T10:48:28.000Z","updated_at":"2025-01-13T07:43:08.000Z","dependencies_parsed_at":"2022-09-02T01:41:44.933Z","dependency_job_id":null,"html_url":"https://github.com/Code-Hex/funcy-mock","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Code-Hex%2Ffuncy-mock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Code-Hex%2Ffuncy-mock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Code-Hex%2Ffuncy-mock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Code-Hex%2Ffuncy-mock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Code-Hex","download_url":"https://codeload.github.com/Code-Hex/funcy-mock/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251685042,"owners_count":21627229,"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":"2024-10-03T12:09:49.077Z","updated_at":"2025-04-30T10:47:20.199Z","avatar_url":"https://github.com/Code-Hex.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# funcy-mock\n[![Go Report Card](https://goreportcard.com/badge/github.com/Code-Hex/funcy-mock)](https://goreportcard.com/report/github.com/Code-Hex/funcy-mock)\n\nfuncy-mock generates mock file from interface go file\n\n## Synopsis\n\nYou can try following:\n\n- `git clone git@github.com:Code-Hex/funcy-mock.git \u0026\u0026 cd funcy-mock/tmp`\n- `funcygen demo.go`\n\nIf you have some question, You run `funcygen -h` or report to issue.\n\n## Description\n\n**THIS TOOL IS BETA QUALITY.**\n\n`funcygen` just by specifying the Go file described the interface, we will generate a go file containing the mock code.\n\n## Installation\n\n    go get github.com/cmd/funcygen\n\n## Generated file\n\nfrom `demo.go` to `demo_mock_for_test.go`\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"github.com/Code-Hex/funcy-mock/tmp/internal/auth\"\n\t\"github.com/Code-Hex/funcy-mock/tmp/internal/user\"\n)\n\ntype UserServiceMock struct {\n\tauth func(context.Context) (*auth.Token, error)\n\tget  func() (*user.Response, error)\n}\n\nfunc NewUserServiceMock() *UserServiceMock {\n\treturn \u0026UserServiceMock{\n\t\tauth: func(context.Context) (*auth.Token, error) { return nil, nil },\n\t\tget:  func() (*user.Response, error) { return nil, nil },\n\t}\n}\n\nfunc (u *UserServiceMock) Auth(ctx context.Context) (*auth.Token, error) {\n\treturn u.auth()\n}\n\nfunc (u *UserServiceMock) SetAuth(f func(context.Context) (*auth.Token, error)) {\n\tif f == nil {\n\t\tpanic(\"You should specify the mock function\")\n\t}\n\tu.auth = f\n}\n\nfunc (u *UserServiceMock) Get() (*user.Response, error) {\n\treturn u.get()\n}\n\nfunc (u *UserServiceMock) SetGet(f func() (*user.Response, error)) {\n\tif f == nil {\n\t\tpanic(\"You should specify the mock function\")\n\t}\n\tu.get = f\n}\n\ntype AuthServiceMock struct {\n\tauth func(context.Context) (*auth.Token, error)\n}\n\nfunc NewAuthServiceMock() *AuthServiceMock {\n\treturn \u0026AuthServiceMock{\n\t\tauth: func(context.Context) (*auth.Token, error) { return nil, nil },\n\t}\n}\n\nfunc (a *AuthServiceMock) Auth(ctx context.Context) (*auth.Token, error) {\n\treturn a.auth()\n}\n\nfunc (a *AuthServiceMock) SetAuth(f func(context.Context) (*auth.Token, error)) {\n\tif f == nil {\n\t\tpanic(\"You should specify the mock function\")\n\t}\n\ta.auth = f\n}\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcode-hex%2Ffuncy-mock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcode-hex%2Ffuncy-mock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcode-hex%2Ffuncy-mock/lists"}