{"id":43277555,"url":"https://github.com/kacperjurak/igorm","last_synced_at":"2026-02-01T16:40:26.051Z","repository":{"id":57491588,"uuid":"127801212","full_name":"kacperjurak/igorm","owner":"kacperjurak","description":"Interface wrapper for gorm.DB","archived":false,"fork":false,"pushed_at":"2020-02-03T21:15:06.000Z","size":5,"stargazers_count":12,"open_issues_count":1,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-06-20T09:19:10.875Z","etag":null,"topics":["go","gorm","interface","mock","mocking","testing","wrapper"],"latest_commit_sha":null,"homepage":null,"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/kacperjurak.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-04-02T19:16:29.000Z","updated_at":"2024-03-19T06:01:02.000Z","dependencies_parsed_at":"2022-08-29T20:31:28.374Z","dependency_job_id":null,"html_url":"https://github.com/kacperjurak/igorm","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/kacperjurak/igorm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kacperjurak%2Figorm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kacperjurak%2Figorm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kacperjurak%2Figorm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kacperjurak%2Figorm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kacperjurak","download_url":"https://codeload.github.com/kacperjurak/igorm/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kacperjurak%2Figorm/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28983079,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-01T16:29:42.054Z","status":"ssl_error","status_checked_at":"2026-02-01T16:29:41.428Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["go","gorm","interface","mock","mocking","testing","wrapper"],"created_at":"2026-02-01T16:40:25.407Z","updated_at":"2026-02-01T16:40:26.046Z","avatar_url":"https://github.com/kacperjurak.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# igorm\n\nInterface wrapper for gorm.DB\n\n\"This is an interface-equivalent of gorm.DB so that those who prefer mocking gorm.DB under test can easily do so. It also adds 2 functions Wrap() and Openw(), to facilitate creating gorm.Gormw instances.\"\n\n### Acknowledgments\n\nThis code was created entirely by [littledot](https://github.com/littledot)\n\nMy only contribution is to export to the external package and create documentation with an example\n\n### Why this is not in the gorm package?\n\n[Jinzhu](https://github.com/jinzhu), the creator of [gorm](https://github.com/jinzhu/gorm) claims that he is not a fan of mock testing without real database and does not want to change his package (see https://github.com/jinzhu/gorm/pull/805). That's why [littledot](https://github.com/littledot) introduced a simple, parallel interface that does not interfere strongly into the main package. [Jinzhu](https://github.com/jinzhu), however, did not implement this function in the gorm, so the igorm package was created (see https://github.com/jinzhu/gorm/pull/1424).\n\nIn my opinion, it is always good to have additional options, in this case mock testing.\n \n### Example\n\nFirst, create or change your existing functions to not use *gorm.DB but instead, use igorm.Gormw interface.\n\n```go\nfunc getUser(db igorm.Gormw) *User {\n}\n```\n\nFrom now on you are not forced to use a *gorm.DB instance, but you can use an instance of any structure that implements all methods from the Gormw interface. That structure is the wrapper available in this package. You can obtain it with Openw() function.\n\n```go\ndb, err := igorm.Openw(dialect, path)\nif err != nil {\n    log.Fatal(err)\n}\n```\n\nAnd now it's possible.\n\n```go\nuser := getUser(db)\n```\n\nOf course, for mock testing or for other purposes, you can create your own structure implementing the Gormw interface (which has all its methods) and implement these methods depending on your needs. Then use it as an value to igorm.Gormw type arguements.\n\n### Wrapper template\n\nCreating your wrapper can be tiring because it has to implement 74 functions from the Gormw interface. That's why I did it for you.\n\nLook at [igorm-mock-template](https://github.com/kacperjurak/igorm-mock-template).\n\n### Note about interfaces and pointers\n\nGorm is ussually used as *gorm.DB (pointer to database instance). For interfaces use values. See explanation at this [link](https://medium.com/@agileseeker/go-interfaces-pointers-4d1d98d5c9c6)\n\n```go\n// NOT\n\nfunc getUser(db *igorm.Gormw) *User {\n}\n```\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkacperjurak%2Figorm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkacperjurak%2Figorm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkacperjurak%2Figorm/lists"}