{"id":19124310,"url":"https://github.com/buildkite/bintest","last_synced_at":"2025-05-05T19:16:21.860Z","repository":{"id":57484740,"uuid":"102948272","full_name":"buildkite/bintest","owner":"buildkite","description":"Golang tools for generating mock binaries for that can be orchestrated in realtime for testing","archived":false,"fork":false,"pushed_at":"2024-08-20T01:50:19.000Z","size":291,"stargazers_count":11,"open_issues_count":1,"forks_count":1,"subscribers_count":19,"default_branch":"master","last_synced_at":"2024-08-21T05:30:12.941Z","etag":null,"topics":["cli","golang","golang-library","mock","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/buildkite.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}},"created_at":"2017-09-09T10:48:30.000Z","updated_at":"2024-08-20T01:49:41.000Z","dependencies_parsed_at":"2024-01-28T04:49:29.978Z","dependency_job_id":"e73e5fa6-081e-4161-ac57-83b340e6e656","html_url":"https://github.com/buildkite/bintest","commit_stats":null,"previous_names":["lox/bintest","lox/go-binproxy"],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/buildkite%2Fbintest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/buildkite%2Fbintest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/buildkite%2Fbintest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/buildkite%2Fbintest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/buildkite","download_url":"https://codeload.github.com/buildkite/bintest/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223789769,"owners_count":17203259,"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":["cli","golang","golang-library","mock","testing"],"created_at":"2024-11-09T05:28:43.866Z","updated_at":"2024-11-09T05:28:44.344Z","avatar_url":"https://github.com/buildkite.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bintest\n\n\u003e :warning: This is an open-sourced tool we use internally. You're welcome to\n\u003e use it, but we are unable to provide support.\n\n[![Documentation](https://godoc.org/github.com/buildkite/bintest?status.svg)](http://godoc.org/github.com/buildkite/bintest)\n\nA set of tools for generating fake binaries that can be used for testing. A binary is compiled and then can be orchestrated from your test suite and later checked for assertions.\n\nMocks can communicate and respond in real-time with the tests that are calling them, which allows for testing complicated dependencies. See https://github.com/buildkite/agent/tree/master/bootstrap/integration for how we use it to test buildkite-agent's bootstrap process.\n\n## Mocks\n\nMocks are your typical mock object, but as an executable that your code can shell out to and then later test assertions on.\n\n```go\nagent, err := bintest.NewMock(\"buildkite-agent\")\nif err != nil {\n  t.Fatal(err)\n}\n\nagent.\n  Expect(\"meta-data\", \"exists\", \"buildkite:git:commit\").\n  AndExitWith(1)\nagent.\n  Expect(\"meta-data\", \"set\", mock.MatchAny()).\n  AndExitWith(0)\nagent.\n  Expect(\"meta-data\", \"set\", \"buildkite:git:branch\", mock.MatchAny()).\n  AndExitWith(0)\n\nagent.CheckAndClose(t)\n```\n\n## Proxies\n\nProxies are what power Mocks.\n\n```go\n// Compile a proxy for the git command that echos some debug\nproxy, err := bintest.CompileProxy(\"git\")\nif err != nil {\n  log.Fatal(err)\n}\n\n// call the proxy like a normal binary\ngo fmt.Println(exec.Command(\"git\", \"test\", \"arguments\").CombinedOutput())\n\n// handle invocations of the proxy binary\nfor call := range proxy.Ch {\n  fmt.Fprintln(call.Stdout, \"Llama party! 🎉\")\n  call.Exit(0)\n}\n\n// Llama party! 🎉\n```\n\n## Credit\n\nInspired by [bats-mock](https://github.com/jasonkarns/bats-mock) and [go-binmock](https://github.com/pivotal-cf/go-binmock).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbuildkite%2Fbintest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbuildkite%2Fbintest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbuildkite%2Fbintest/lists"}