{"id":34126465,"url":"https://github.com/larhun/golden","last_synced_at":"2026-06-09T09:31:27.029Z","repository":{"id":57552789,"uuid":"123681614","full_name":"larhun/golden","owner":"larhun","description":"Package for testing commands using smart validation strings and gold master files.","archived":false,"fork":false,"pushed_at":"2019-08-01T09:31:16.000Z","size":16,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-12-17T10:13:53.662Z","etag":null,"topics":["command","testing"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/larhun.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":"2018-03-03T10:24:14.000Z","updated_at":"2019-08-01T09:31:17.000Z","dependencies_parsed_at":"2022-09-26T18:50:54.038Z","dependency_job_id":null,"html_url":"https://github.com/larhun/golden","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/larhun/golden","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/larhun%2Fgolden","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/larhun%2Fgolden/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/larhun%2Fgolden/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/larhun%2Fgolden/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/larhun","download_url":"https://codeload.github.com/larhun/golden/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/larhun%2Fgolden/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34101065,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-09T02:00:06.510Z","response_time":63,"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":["command","testing"],"created_at":"2025-12-14T23:42:00.929Z","updated_at":"2026-06-09T09:31:27.009Z","avatar_url":"https://github.com/larhun.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# golden\n\n[![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)\n[![Coverage Status](http://codecov.io/github/larhun/golden/coverage.svg?branch=master)](http://codecov.io/github/larhun/golden?branch=master)\n[![Build Status](https://travis-ci.org/larhun/golden.png?branch=master)](https://travis-ci.org/larhun/golden)\n[![Go Report Card](https://goreportcard.com/badge/larhun/golden)](https://goreportcard.com/report/larhun/golden)\n[![GoDoc](https://godoc.org/github.com/larhun/golden?status.svg)](https://godoc.org/github.com/larhun/golden)\n\n----\n\nPackage golden provides functions for testing commands using smart validation\nstrings and gold master files.\n\nA command must implement the `Runner` interface. It represents a black box\nsystem with inputs (the argument list) and outputs (the standard and error\noutputs, the panic and error messages, the exit code, and an optional file\noutput). A test case is a value of `Case` type. It represents a set of\ninput and output values. A test is performed using the `Test` function.\n\nThe following example tests a command named `\"hello\"` that should print `\"Hello\nWorld!\"` to its standard output with an argument list equal to `[]string{\"hello\",\n\"World\"}` (the first argument must be the command name).\n\n```Go\n    var command Runner = ... // the \"hello\" command\n\n    func TestXxx(t *testing.T) {\n        Test(t, command, []Case{{\n            Name:       \"output\",                   // test case name\n            Args:       []string{\"hello\", \"World\"}, // argument list\n            WantStdout: \"Hello World!\",             // expected standard output\n        })\n    }\n```\n\nThe command under test may be implemented using inner functions or may be\ngenerated from an external `hello` program using the `Program` function:\n\n```Go\n    var command = Program(\"hello\", nil)\n```\n\nThe `Test` function supports smart validation strings and gold master files that\ndefine very flexible matches with a very simple syntax (see the package\ndocumentation for details). The `\"...\"` ellipsis is used to encode a partial\nmatch:\n\n```Go\n    \"Hello...\"     // match \"Hello\" prefix\n    \"...World!\"    // match \"World!\" suffix\n    \"...World...\"  // match \"World\" substring\n```\n\nThe `\"^\"` and `\"$\"` delimiters are used to encode a pattern matching:\n\n```Go\n    \"^.*(Hello|World).*$\" // match \"Hello\" or \"World\" substring\n```\n\nThe `\"golden\"` term is used to encode a value stored by a gold master file:\n\n```Go\n    \"golden.json\" // match file testdata/golden/TestXxx-output.json\n```\n\nThe gold master pattern is commonly used when testing complex output: the\nexpected string is saved to a file, the gold master, rather than to a validation\nstring. All the gold masters used by `TestXxx` are updated by running the test\nwith the `update` flag:\n\n```Shell\n    go test -run TestXxx -update\n```\n\nAll the gold masters are updates by running:\n\n```Shell\n    go test -update\n```\n\nSee the testing files for usage examples.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flarhun%2Fgolden","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flarhun%2Fgolden","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flarhun%2Fgolden/lists"}