Ecosyste.ms: Packages

An open API service providing package, version and dependency metadata of many open source software ecosystems and registries.

Top 8.2% on proxy.golang.org

proxy.golang.org : github.com/larhun/golden

Package golden provides functions for testing commands using smart strings and gold masters. A command must implement the Runner interface. It represents a black box system with inputs (the argument list) and outputs (the standard and error outputs, the panic and error messages, the exit code, and an optional file output). A test case is a value of Case type. It represents a set of input and output values. A test is performed using the Test function. The following example tests a command named "hello" that should print "Hello World!" to its standard output with an argument list equal to []string{"hello", "World"} (the first argument must be the command name). The command under test may be implemented using inner functions or may be generated from an external hello program using the Program function: The Test function supports smart validation strings and gold master files that define very flexible matches. The gold master pattern is commonly used when testing complex output: the expected string is saved to a file, the gold master, rather than to a validation string. The syntax of a smart validation string is very simple. A string equal to "golden" with an optional extension encodes a match to the content of a gold master file with the same extension. The file is stored in testdata/golden with name derived from the test case name: A string representing a valid regular expression delimited by the "^" and "$" characters encodes a full pattern matching: A string starting or ending with the "..." ellipsis encodes a partial match: A string escaped by the equal symbol represents the substring after the symbol: Any other string represents itself: All the gold masters used by TestXxx are updated by running the test with the update flag: All the gold masters are updates by running: See the testing files for usage examples.

Registry - Source - Documentation - JSON
purl: pkg:golang/github.com/larhun/golden
Keywords: command, testing
License: BSD-3-Clause
Latest release: almost 5 years ago
First release: almost 5 years ago
Namespace: github.com/larhun
Stars: 1 on GitHub
Forks: 0 on GitHub
See more repository details: repos.ecosyste.ms
Last synced: 29 days ago

    Loading...
    Readme
    Loading...