{"id":18866834,"url":"https://github.com/ing-bank/gintestutil","last_synced_at":"2026-04-26T16:32:37.624Z","repository":{"id":152315384,"uuid":"617899798","full_name":"ing-bank/gintestutil","owner":"ing-bank","description":"Utilities for writing unit-tests with Gin","archived":false,"fork":false,"pushed_at":"2024-03-16T14:51:56.000Z","size":29,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-05-30T14:51:13.624Z","etag":null,"topics":["context","gin","go","golang","test","testing","unit","utilities","utility"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/ing-bank/gintestutil","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/ing-bank.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-03-23T10:50:49.000Z","updated_at":"2023-03-23T21:31:11.000Z","dependencies_parsed_at":"2024-03-16T11:44:36.971Z","dependency_job_id":"1982b0d5-5f5b-44b4-8db7-94547c36f1d9","html_url":"https://github.com/ing-bank/gintestutil","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/ing-bank/gintestutil","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ing-bank%2Fgintestutil","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ing-bank%2Fgintestutil/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ing-bank%2Fgintestutil/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ing-bank%2Fgintestutil/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ing-bank","download_url":"https://codeload.github.com/ing-bank/gintestutil/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ing-bank%2Fgintestutil/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32305035,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T09:34:17.070Z","status":"ssl_error","status_checked_at":"2026-04-26T09:34:00.993Z","response_time":129,"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":["context","gin","go","golang","test","testing","unit","utilities","utility"],"created_at":"2024-11-08T05:07:40.776Z","updated_at":"2026-04-26T16:32:37.605Z","avatar_url":"https://github.com/ing-bank.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🦁 Gin Test Utils\n\n[![Go package](https://github.com/ing-bank/gintestutil/actions/workflows/test.yaml/badge.svg)](https://github.com/ing-bank/gintestutil/actions/workflows/test.yaml)\n![GitHub](https://img.shields.io/github/license/ing-bank/gintestutil)\n![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/ing-bank/gintestutil)\n\nSmall utility functions for testing Gin-related code.\nSuch as the creation of a gin context and wait groups with callbacks.\n\n## ⬇️ Installation\n\n`go get github.com/ing-bank/gintestutil`\n\n## 📋 Usage\n\n### Context creation\n\n```go\npackage main\n\nimport (\n\t\"net/http\"\n\t\"testing\"\n\t\"github.com/ing-bank/gintestutil\"\n)\n\ntype TestObject struct {\n\tName string\n}\n\nfunc TestProductController_Post_CreatesProducts(t *testing.T) {\n\t// Arrange\n\tcontext, writer := gintestutil.PrepareRequest(t,\n\t\tgintestutil.WithJsonBody(t, TestObject{Name: \"test\"}),\n\t\tgintestutil.WithMethod(http.MethodPost),\n\t\tgintestutil.WithUrl(\"https://my-website.com\"),\n\t\tgintestutil.WithHeaders(http.Header{\"X-Example\": []string{\"A\", \"B\"}}),\n\t\tgintestutil.WithUrlParams(map[string]any{\"category\": \"barbecue\"}),\n\t    gintestutil.WithQueryParams(map[string]any{\"force\": \"true\"}))\n\n\t// [...]\n}\n```\n\n### Response Assertions\n\n```go\npackage main\n\nimport (\n\t\"github.com/stretchr/testify/assert\"\n\t\"net/http\"\n\t\"testing\"\n\t\"github.com/ing-bank/gintestutil\"\n)\n\ntype TestObject struct {\n\tName string\n}\n\nfunc TestProductController_Index_ReturnsAllProducts(t *testing.T) {\n\t// Arrange\n\tcontext, writer := gintestutil.PrepareRequest(t)\n\n\t// [...]\n\n\t// Assert\n\tvar actual []TestObject\n\tif gintestutil.Response(t, \u0026actual, http.StatusOK, writer.Result()) {\n\t\tassert.Equal(t, []TestObject{}, actual)\n\t}\n}\n```\n\n### Hooks\n\n```go\npackage main\n\nimport (\n\t\"github.com/gin-gonic/gin\"\n\t\"github.com/ing-bank/gintestutil\"\n\t\"net/http\"\n\t\"net/http/httptest\"\n\t\"time\"\n\t\"testing\"\n)\n\nfunc TestHelloController(t *testing.T) {\n\t// Arrange\n\tginContext := gin.Default()\n\n\t// create expectation\n\texpectation := gintestutil.ExpectCalled(t, ginContext, \"/hello-world\")\n\n\tginContext.GET(\"/hello-world\", func(context *gin.Context) {\n\t\tcontext.Status(http.StatusOK)\n\t})\n\n\t// create webserver\n\tts := httptest.NewServer(ginContext)\n\n\t// Send request to webserver path\n\t_, _ = http.Get(fmt.Sprintf(\"%s/hello-world\", ts.URL))\n\n\t// Wait for expectation in bounded time\n\tif ok := gintestutil.EnsureCompletion(t, expectation); !ok {\n\t\t// do something\n\t}\n}\n```\n\n## 🚀 Development\n\n1. Clone the repository\n2. Run `make tools` to install necessary tools\n3. Run `make t` to run unit tests\n4. Run `make fmt` to format code\n4. Run `make lint` to lint your code\n\nYou can run `make` to see a list of useful commands.\n\n## 🔭 Future Plans\n\nNothing here yet!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fing-bank%2Fgintestutil","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fing-bank%2Fgintestutil","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fing-bank%2Fgintestutil/lists"}