{"id":28349741,"url":"https://github.com/mkch/asserting","last_synced_at":"2025-08-25T08:11:39.545Z","repository":{"id":57491604,"uuid":"206000923","full_name":"mkch/asserting","owner":"mkch","description":"Golang unit test utility.","archived":false,"fork":false,"pushed_at":"2019-10-01T06:00:25.000Z","size":22,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-04T01:56:48.867Z","etag":null,"topics":[],"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/mkch.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":"2019-09-03T06:05:05.000Z","updated_at":"2020-07-01T00:14:42.000Z","dependencies_parsed_at":"2022-08-30T23:22:22.932Z","dependency_job_id":null,"html_url":"https://github.com/mkch/asserting","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mkch/asserting","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkch%2Fasserting","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkch%2Fasserting/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkch%2Fasserting/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkch%2Fasserting/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mkch","download_url":"https://codeload.github.com/mkch/asserting/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkch%2Fasserting/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272030996,"owners_count":24861638,"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","status":"online","status_checked_at":"2025-08-25T02:00:12.092Z","response_time":1107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2025-05-27T20:11:00.439Z","updated_at":"2025-08-25T08:11:39.531Z","avatar_url":"https://github.com/mkch.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# asserting\n\n Golang unit test utility.\n\n## Example\n\nmypackage.go\n\n    package mypackage\n\n    func SomeOddNumber() int {\n        return 1333\n    }\n\n    func PanicWith100() {\n        panic(100)\n    }\n\n    func Div(a, b int) int {\n        if b == 0 {\n            panic(\"can' div by 0\")\n        }\n        return a / b\n    }\n\nmypackage_test.go\n\n    package mypackage\n\n    import (\n        \"strconv\"\n        \"testing\"\n\n        . \"github.com/mkch/asserting\"\n    )\n\n    func TestAdd(t1 *testing.T) {\n        t := TB{t1}\n        // Asserts 1+1 == 2\n        t.Assert(1+1, Equals(2))\n        // Asserts 1+1 != 0 with custom failure message.\n        t.Assert(1+1, NotEquals(0).SetMessage(\"1+1 != 0\"))\n    }\n\n    func TestSomeOddNumber(t1 *testing.T) {\n        t := TB{t1}\n        // Asserts SomeOddNumber() returns an odd number.\n        t.Assert(SomeOddNumber(), Matches(\n            func(v interface{}) bool {\n                return v.(int)%2 != 0\n            }).\n            SetMessage(\"Not an odd number\"))\n    }\n\n    func TestPanicWith100(t1 *testing.T) {\n        t := TB{t1}\n        // Asserts calling a function must panic with 100.\n        t.Assert(PanicWith100, Panics(100))\n        // Asserts calling a function must panic with a string.\n        t.Assert(func() { Div(1, 0) },\n            PanicMatches(\n                func(v interface{}) bool {\n                    _, ok := v.(string)\n                    return ok\n                }))\n    }\n\n    func TestAtoi(t1 *testing.T) {\n        t := TB{t1}\n        // Test strconv.Atoi who returns an int and an error.\n        // If the error value of Atoi is not nil, or the int\n        // value is not 1, the assertion fails.\n        t.Assert(ValueError(strconv.Atoi(\"1\")), Equals(1))\n    }  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmkch%2Fasserting","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmkch%2Fasserting","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmkch%2Fasserting/lists"}