{"id":36486589,"url":"https://github.com/deadkrolik/godbt","last_synced_at":"2026-01-12T01:51:52.190Z","repository":{"id":53494783,"uuid":"97459625","full_name":"deadkrolik/godbt","owner":"deadkrolik","description":"Golang database testing package like PHP DBunit","archived":false,"fork":false,"pushed_at":"2021-03-28T13:45:30.000Z","size":13,"stargazers_count":2,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-06-19T19:42:16.245Z","etag":null,"topics":["dbunit","golang","mysql","testing"],"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/deadkrolik.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":"2017-07-17T09:34:45.000Z","updated_at":"2019-11-21T06:08:52.000Z","dependencies_parsed_at":"2022-08-30T00:10:56.941Z","dependency_job_id":null,"html_url":"https://github.com/deadkrolik/godbt","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/deadkrolik/godbt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deadkrolik%2Fgodbt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deadkrolik%2Fgodbt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deadkrolik%2Fgodbt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deadkrolik%2Fgodbt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/deadkrolik","download_url":"https://codeload.github.com/deadkrolik/godbt/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deadkrolik%2Fgodbt/sbom","scorecard":{"id":330677,"data":{"date":"2025-08-11","repo":{"name":"github.com/deadkrolik/godbt","commit":"54fc5f9fc22986f02d7eabf39a7fd831e0b65e8c"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/7 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":"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":"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":"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":"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":"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":"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":"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":"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":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"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":"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":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"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"}}]},"last_synced_at":"2025-08-18T03:30:35.689Z","repository_id":53494783,"created_at":"2025-08-18T03:30:35.689Z","updated_at":"2025-08-18T03:30:35.689Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28331258,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-12T00:36:25.062Z","status":"ssl_error","status_checked_at":"2026-01-12T00:36:15.229Z","response_time":60,"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":["dbunit","golang","mysql","testing"],"created_at":"2026-01-12T01:51:52.067Z","updated_at":"2026-01-12T01:51:52.176Z","avatar_url":"https://github.com/deadkrolik.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GODBT\nGolang package for database testing (like PHP DBunit)\n\n## Start using it\n\n1. Download and install it:\n\n```sh\n$ go get -u github.com/deadkrolik/godbt\n```\n\n2. Import it in your code:\n\n```go\npackage test\n\nimport (\n    \"github.com/deadkrolik/godbt\"\n    \"github.com/deadkrolik/godbt/contract\"\n)\n```\n3. Create test object, shared for all test functions and configure mysql conection:\n\n```go\nvar (\n    tester *godbt.Tester\n    err    error\n)\n\nfunc init() {\n    tester, err = godbt.GetTester(contract.InstallerConfig{\n        Type:        \"mysql\",\n        ConnString:  \"user:password@/database?charset=utf8\u0026parseTime=True\u0026loc=Local\",\n        ClearMethod: contract.ClearMethodTruncate,\n    })\n    if err != nil {\n        panic(err.Error())\n    }\n}\n```\n## Loading images\n\nImage - set of rows you can load from different sources.\n\n1. XML-file as a source:\n\n```go\nimage, err := tester.GetImageManager().LoadImage(\"path/to/file.xml\")\nif err != nil {\n    //...\n}\n```\n\n2. XML-formatted string as a source:\n\n```go\nimage, err := tester.GetImageManager().LoadImage(`\n\u003c?xml version=\"1.0\" ?\u003e\n\u003cdataset\u003e\n    \u003cdata id=\"1\" k1=\"1\" k2=\"2\"/\u003e\n    \u003cdata id=\"2\" k1=\"2\" k2=\"3\"/\u003e\n\u003c/dataset\u003e`)\nif err != nil {\n    //...\n}\n```\n\nRoot tag should be \"dataset\", \"data\" in example is a table name, \"k1\", \"k2\" - columns names.\n\n3. Second optional parameter for LoadImage is a list of replacement functions:\n\n```go\ncontract.ModifiersList{\n    \"value1\": func(table string, key string, value string) string {\n        return \"modified_\" + value\n    },\n})\n```\n\nIf we have XML-file like that:\n\n```xml\n\u003c?xml version=\"1.0\" ?\u003e\n\u003cdataset\u003e\n    \u003cdata k1=\"value1\" k2=\"value2\" k3=\"---value1---\"/\u003e\n\u003c/dataset\u003e\n```\n\nThe result Image will have k1=\"modified_value1\", k2=\"value2\", k3=\"---modified_value1---\". So replacement\nfunction will be called if attribute value contains your string. It can be used to deal with templates (replace\n\"{CURRENT_DATE}\" to real date, for example).\n\n## Installing images\n\n1. Here is a code, that inserts dataset to real database: \n\n```go\nerr = tester.GetInstaller().InstallImage(image)\nif err != nil {\n    //...\n}\n```\n\n2. It can be done in transaction (it's faster, but you can't use ClearMethodTruncate):\n\n```go\ninstaller := tester.GetInstaller()\nerr = installer.WithTransaction()\nif err != nil {\n    //...\n}\n\nerr = installer.SetClearMethod(contract.ClearMethodDeleteAll).InstallImage(yourImage)\nif err != nil {\n    //...\n}\n\n//here is you app code\n\nerr = installer.Rollback()\nif err != nil {\n    //...\n}\n```\n\n## Checking test results\n\n1. After loading and installing image you should run your real app code, that works with database.\n \n2. Then you can check if you database state correct and the same as you predefined state, that can be described as another Image.\n\n3. Checking count of rows in real table:\n\n```go\ncount, err := tester.GetInstaller().GetTableRowsCount(\"data\")\nif err != nil {\n    //...\n}\n//count assert ...\n```\n\n4. Checking state:\n\n```go\nrealImage, err := tester.GetInstaller().GetTableImage(\n    \"data\",//table name\n    []string{\"column1\", \"column2\", \"column3\"},//only columns\n    map[string]int{//rows order is important\n        \"column1\": contract.SortAsc,\n        \"column2\": contract.SortDesc,\n    },\n)\nif err != nil {\n    //...\n}\n\ntestImage, err := tester.GetImageManager().LoadImage(`\n     \u003c?xml version=\"1.0\" ?\u003e\n     \u003cdataset\u003e\n         \u003cdata column1=\"1\" column2=\"2\" column3=\"1\"/\u003e\n         \u003cdata column1=\"2\" column2=\"2\" column3=\"2\"/\u003e\n     \u003c/dataset\u003e`\n )\n if err != nil {\n     //...\n }\n\ndiffs := tester.GetImageManager().GetImagesDiff(testImage, realImage)\nt.Log(diffs)\n```\n\nIf images a same *diffs* will have zero length. If not - will contain error messages.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeadkrolik%2Fgodbt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeadkrolik%2Fgodbt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeadkrolik%2Fgodbt/lists"}