{"id":16939427,"url":"https://github.com/a8m/expect","last_synced_at":"2025-03-22T12:32:19.812Z","repository":{"id":30340188,"uuid":"33892574","full_name":"a8m/expect","owner":"a8m","description":"Minimalistic BDD-style assertions for Go (inspired by expect.js)","archived":false,"fork":false,"pushed_at":"2016-11-29T04:20:10.000Z","size":57,"stargazers_count":32,"open_issues_count":3,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-14T21:04:48.096Z","etag":null,"topics":["assert","bdd","expect","go"],"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/a8m.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":"2015-04-13T20:37:17.000Z","updated_at":"2024-03-07T12:57:47.000Z","dependencies_parsed_at":"2022-07-31T09:08:01.440Z","dependency_job_id":null,"html_url":"https://github.com/a8m/expect","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a8m%2Fexpect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a8m%2Fexpect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a8m%2Fexpect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a8m%2Fexpect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/a8m","download_url":"https://codeload.github.com/a8m/expect/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221829407,"owners_count":16887588,"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","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":["assert","bdd","expect","go"],"created_at":"2024-10-13T21:04:44.308Z","updated_at":"2024-10-28T12:51:39.897Z","avatar_url":"https://github.com/a8m.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Expect.go  [![Build status][travis-image]][travis-url] [![License][license-image]][license-url] [![GoDoc][godoc-img]][godoc-url]\n\u003e Minimalistic BDD-style assertions for Go (inspired by expect.js)\n\n```go\nexpect := expect.New(t)\n\n// Numbers\nexpect(10).To.Be.Above(1).And.Below(20)\nexpect(5).Not.To.Be.Within(0, 4)\n\n// Strings\nexpect(\"foobarbaz\").To.StartWith(\"foo\").And.EndWith(\"baz\").And.Contains(\"bar\")\nexpect(\"Foo\").To.Match(\"(?i)foo\")\n\n// Equal\nexpect(res.StatusCode).To.Equal(200)\nexpect(false).Not.To.Equal(\"false\")\nexpect(map[int]int{}).To.Equal(map[int]int{})\n\n// Empty\nexpect(map[int]int{}).To.Be.Empty()\nexpect(\"\").To.Be.Empty()\nexpect([2]int{}).Not.To.Be.Empty()\n\n// Ok (i.e: not \"\", 0, false, nil)\nexpect(val).To.Be.Ok()\nexpect(false).Not.To.Be.Ok()\n\n// True/False\nexpect(true).To.Be.True()\nexpect(false).To.Be.False()\n\n// Type Assertion\nexpect(\"\").To.Be.String()\nexpect(0).To.Be.Int()\nexpect(1.1).To.Be.Float()\nexpect(1).Not.To.Be.Bool()\nexpect(map[string]int{}).To.Be.Map()\nexpect([...]int{1}).To.Be.Array()\nexpect([]string{\"a\"}).To.Be.Slice()\nexpect(ch).To.Be.Chan()\nexpect(struct{}{}).To.Be.Struct()\nexpect(\u0026struct{}{}).To.Be.Ptr()\nexpect(nil).To.Be.Nil()\nexpect(Person{}).To.Be.Type(\"Person\")\n\n// Len\nexpect(\"foo\").To.Have.Len(3)\nexpect([]int{1, 2}).To.Have.Len(2)\n\n// Cap\nexpect(make([]byte, 2, 10)).To.Have.Cap(10)\nexpect([2]int{}).To.Have.Cap(2)\n\n// Maps\nm1 := map[string]int{\n\t\"a\": 1,\n\t\"b\": 2,\n}\nexpect(m1).To.Have.Key(\"a\")\nexpect(m1).To.Have.Key(\"a\", 1) // With value\nexpect(m1).To.Have.Keys(\"a\", \"b\")\n\n// Structs\np := struct {\n\tX, Y int\n}{1, 3}\nexpect(p).To.Have.Field(\"Y\", 3).And.Field(\"X\", 1)\n\n// Functions\nexpect(func() {}).Not.To.Panic()\nexpect(func() {\n\tpanic(\"foo\")\n}).To.Panic()\nexpect(func() {\n\tpanic(\"bar\")\n}).To.Panic(\"bar\")\n\n// FailNow\nexpect(\"foo\").To.Equal(\"bar\").Else.FailNow()\n```\n\n## License\nMIT\n\n[travis-image]: https://img.shields.io/travis/a8m/expect.svg?style=flat-square\n[travis-url]: https://travis-ci.org/a8m/expect\n[license-url]:   LICENSE\n[license-image]: https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square\n[godoc-url]:     https://godoc.org/github.com/a8m/expect\n[godoc-img]:     https://img.shields.io/badge/godoc-reference-blue.svg?style=flat-square\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fa8m%2Fexpect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fa8m%2Fexpect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fa8m%2Fexpect/lists"}