{"id":37114575,"url":"https://github.com/virgild/testutils","last_synced_at":"2026-01-14T13:28:41.844Z","repository":{"id":57577573,"uuid":"359217829","full_name":"virgild/testutils","owner":"virgild","description":"testutils contains packages that help in testing Go programs. The first package is called mysqlbox, and it allows your test code to start a MySQL server that runs in a Docker container. Your tests can use this if you need to run them against a real MySQL server.","archived":false,"fork":false,"pushed_at":"2021-05-17T21:47:39.000Z","size":219,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-27T12:33:48.819Z","etag":null,"topics":["docker","go","mysql","testing"],"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/virgild.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":"2021-04-18T18:04:32.000Z","updated_at":"2021-05-17T21:47:42.000Z","dependencies_parsed_at":"2022-09-11T23:40:48.536Z","dependency_job_id":null,"html_url":"https://github.com/virgild/testutils","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/virgild/testutils","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/virgild%2Ftestutils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/virgild%2Ftestutils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/virgild%2Ftestutils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/virgild%2Ftestutils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/virgild","download_url":"https://codeload.github.com/virgild/testutils/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/virgild%2Ftestutils/sbom","scorecard":{"id":923138,"data":{"date":"2025-08-11","repo":{"name":"github.com/virgild/testutils","commit":"953be78a0bb781cd6eb26bc49be7daf77e3df86e"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.7,"checks":[{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Code-Review","score":0,"reason":"Found 0/25 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":0,"reason":"43 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GO-2022-0921 / GHSA-c72p-9xmj-rx3w","Warn: Project is vulnerable to: GO-2022-0938 / GHSA-c2h3-6mxw-7mvq","Warn: Project is vulnerable to: GO-2022-0360 / GHSA-5j5w-g665-5m35","Warn: Project is vulnerable to: GO-2022-0344 / GHSA-crp2-qrr5-8pq7","Warn: Project is vulnerable to: GO-2024-2846 / GHSA-c9cp-9c75-9v8c","Warn: Project is vulnerable to: GO-2022-0482 / GHSA-5ffw-gxpp-mxpf","Warn: Project is vulnerable to: GO-2022-1147 / GHSA-2qjp-425j-52j9","Warn: Project is vulnerable to: GO-2023-1573 / GHSA-259w-8hf6-59c2","Warn: Project is vulnerable to: GO-2023-1574 / GHSA-hmfx-3pcx-653p","Warn: Project is vulnerable to: GO-2023-2412 / GHSA-7ww5-4wqc-m92c","Warn: Project is vulnerable to: GO-2025-3528 / GHSA-265r-hfxg-fhmg","Warn: Project is vulnerable to: GO-2022-0379 / GHSA-qq97-vm5h-rrhg","Warn: Project is vulnerable to: GHSA-hqxw-f8mx-cpmw","Warn: Project is vulnerable to: GO-2024-2500 / GHSA-3fwx-pjgw-3558","Warn: Project is vulnerable to: GO-2024-2913 / GHSA-v994-f8vw-g7j4","Warn: Project is vulnerable to: GO-2024-2914 / GHSA-xmmx-7jpf-fx42","Warn: Project is vulnerable to: GO-2022-0390 / GHSA-2mm7-x5h6-5pvq","Warn: Project is vulnerable to: GO-2022-0985 / GHSA-rc4r-wh2q-q6c4","Warn: Project is vulnerable to: GO-2022-1107 / GHSA-vp35-85q5-9f25","Warn: Project is vulnerable to: GO-2023-1699 / GHSA-232p-vwff-86mp","Warn: Project is vulnerable to: GO-2023-1700 / GHSA-33pg-m6jh-5237","Warn: Project is vulnerable to: GO-2023-1701 / GHSA-6wrf-mxfj-pf5p","Warn: Project is vulnerable to: GHSA-jq35-85cj-fj4p","Warn: Project is vulnerable to: GHSA-mq39-4gv4-mvpx","Warn: Project is vulnerable to: GO-2024-3005 / GHSA-v23v-6jw2-98fq","Warn: Project is vulnerable to: GO-2024-2512 / GHSA-xw73-rw38-6vjc","Warn: Project is vulnerable to: GO-2025-3829 / GHSA-4vq8-7jfc-9cvp","Warn: Project is vulnerable to: GHSA-77vh-xpmg-72qh","Warn: Project is vulnerable to: GO-2022-0236 / GHSA-h86h-8ppg-mxmh","Warn: Project is vulnerable to: GO-2021-0238 / GHSA-83g2-8m93-v3w7","Warn: Project is vulnerable to: GO-2022-0288","Warn: Project is vulnerable to: GO-2022-0969 / GHSA-69cg-p879-7622","Warn: Project is vulnerable to: GO-2022-1144 / GHSA-xrjj-mj9h-534m","Warn: Project is vulnerable to: GO-2023-1571 / GHSA-vvpx-j8f3-3w6h","Warn: Project is vulnerable to: GO-2023-1988 / GHSA-2wrh-6pvc-2jm9","Warn: Project is vulnerable to: GO-2023-2102 / GHSA-4374-p667-p6c8","Warn: Project is vulnerable to: GO-2023-2153 / GHSA-m425-mq94-257g / GHSA-qppj-fm5r-hxr3","Warn: Project is vulnerable to: GO-2024-2687 / GHSA-4v7x-pqxf-cx7m","Warn: Project is vulnerable to: GO-2024-3333","Warn: Project is vulnerable to: GO-2025-3503 / GHSA-qxp5-gwg8-xv66","Warn: Project is vulnerable to: GO-2025-3595 / GHSA-vvgc-356p-c3xw","Warn: Project is vulnerable to: GO-2022-0493 / GHSA-p782-xgp4-8hr8","Warn: Project is vulnerable to: GO-2022-0603 / GHSA-hp87-p4gw-j4gq"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-25T06:36:40.368Z","repository_id":57577573,"created_at":"2025-08-25T06:36:40.369Z","updated_at":"2025-08-25T06:36:40.369Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28421207,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T10:47:48.104Z","status":"ssl_error","status_checked_at":"2026-01-14T10:46:19.031Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":["docker","go","mysql","testing"],"created_at":"2026-01-14T13:28:41.198Z","updated_at":"2026-01-14T13:28:41.829Z","avatar_url":"https://github.com/virgild.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# This package is now deprecated and replaced by a [mysqlbox package](https://github.com/virgild/mysqlbox) on its own.\n---\n# testutils\n\ntestutils contains packages that help in testing Go programs. The first package is called **mysqlbox**, and it allows your test code to start a MySQL server in a Docker container. Your tests can use this if you need to run them against a real MySQL server.\n\n## mysqlbox\n\n![MySQLBox logo](https://github.com/virgild/testutils/blob/main/static/logo.png?raw=true)\n\n**mysqlbox** creates a ready to use MySQL server in a Docker container that can be\nused in Go tests. The `Start()` function returns a `MySQLBox` that has a container running MySQL server. \nIt has a `Stop()` function that stops the container. The `DB()` function returns a connected \n`sql.DB` that can be used to send queries to MySQL.\n\n### Install mysqlbox\n\n```sh\ngo get github.com/virgild/testutils/mysqlbox\n```\n\n### Basic usage\n\n```go\npackage mytests\n\nimport (\n\t\"testing\"\n\n\t\"github.com/virgild/testutils/mysqlbox\"\n)\n\nfunc TestMyCode(t *testing.T) {\n\t// Start MySQL container\n\tbox, err := mysqlbox.Start(\u0026mysqlbox.Config{})\n\tif err != nil {\n\t    t.Fatal(err)\n\t}\n\n\t// Register the stop func to stop the container after the test.\n\tt.Cleanup(func() {\n\t    err := b.Stop()\n\t    if err != nil {\n\t        t.Fatal(err)\n\t    }\n\t})\n\t\n\t// Use the sql.DB object to query the database.\n\tbox.DB().QueryRow(\"SELECT NOW()\")\n\t\n\tvar now time.Time\n\terr = row.Scan(\u0026row)\n\tif err != nil {\n\t    t.Error(err)\n\t}\n\t\n\tif now.IsZero() {\n\t    t.Error(\"now is zero\")\n\t}\n}\n```\n\n### Other Features\n\n#### Initial script\n\nMySQL server can be started with an initial SQL script that is run after the service starts. It can be provided as an `io.Reader` or a `[]byte` buffer.\n\n##### Specifying the initial script from a file/reader\n\n```go\nschemaFile, err := os.Open(\"testdata/schema.sql\")\nif err != nil {\n    t.Fatal(err)\n}\ndefer schemaFile.Close()\n\nbox, err = mysqlbox.Start(\u0026Config{\n    InitialSQL: mysqlbox.DataFromReader(schemaFile),\n}\nif err != nil {\n    t.Fatal(err)\n}\n\nt.Cleanup(func() {\n    err := b.Stop()\n    if err != nil {\n        t.Fatal(err)\n    }\n})\n```\n\n##### Specifying the initial script from a byte buffer\n\n```go\nsql := []byte(`\n\tCREATE TABLE users\n\t(\n\t\tid         varchar(128) NOT NULL,\n\t\temail      varchar(128) NOT NULL,\n\t\tcreated_at datetime     NOT NULL,\n\t\tupdated_at datetime     NOT NULL,\n\t\tPRIMARY KEY (id),\n\t\tUNIQUE KEY users_email_uindex (email),\n\t\tUNIQUE KEY users_id_uindex (id)\n\t) ENGINE = InnoDB\n\tDEFAULT CHARSET = utf8mb4;\n`)\n\nb, err := mysqlbox.Start(\u0026Config{\n\tInitialSQL: mysqlbox.DataFromBuffer(sql),\n})\nif err != nil {\n\tt.Fatal(err)\n}\nt.Cleanup(func() {\n\terr := b.Stop()\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n})\n\nquery := \"INSERT INTO users (id, email, created_at, updated_at) VALUES (?, ?, ?, ?)\"\nnow := time.Now()\n_, err = b.DB().Exec(query, \"U-TEST1\", \"user1@example.com\", now, now)\nif err != nil {\n\tt.Error(err)\n}\n```\n\n#### Cleaning tables\n\nAll tables can be truncated by calling `CleanAllTables()`. This runs `TRUNCATE` on all tables in the database, except for those specified in the `Config.DoNotCleanTables` array. Another function called `CleanTables()` can  be used to truncate just specific tables you want to clean. Any table passed to `CleanTables()` will always truncate it even if it is included in the `DoNotCleanTables` list.\n\n### Using MySQLBox outside tests\n\nIt is not recommended to use MySQLBox as a normal MySQL database. This component is designed to be ephemeral, and no precautions are implemented to protect the database data.\n\n### Troubleshooting and other notes\n\n* I forgot to call `Stop()` and now I have a several containers that are still running.\n\n    The following command can be run to stop the containers started by `MySQLBox`.\n\n    ```sh\n    docker ps -a -f \"label=com.github.virgild.testutils.mysqlbox\" --format '{{.ID}}' | xargs docker stop\n    ```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvirgild%2Ftestutils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvirgild%2Ftestutils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvirgild%2Ftestutils/lists"}