Documentation
¶
Index ¶
Examples ¶
Constants ¶
const Marker = "---\n"
Marker is a separator between a golden file comment and the content.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Goldy ¶ added in v0.7.0
type Goldy struct {
// contains filtered or unexported fields
}
Goldy represents a golden file.
Example golden file:
Multi line golden file documentation. --- Content line #1. Content line #2.
func Open ¶ added in v0.7.0
Open instantiates Goldy based on the provided path to the golden file and options. The golden file content starts after the mandatory Marker line, anything before it is ignored. It's customary to have short golden file documentation before the marker.
Example ¶
package main
import (
"fmt"
"github.com/ctx42/testing/internal/core"
"github.com/ctx42/testing/pkg/goldy"
)
func main() {
tspy := core.NewSpy()
gld := goldy.Open(tspy, "testdata/test_case1.gld")
fmt.Println(gld.String())
}
Output: Content #1. Content #2.
func (*Goldy) Save ¶ added in v0.7.0
func (gld *Goldy) Save()
Save saves the golden file to the original path.
func (*Goldy) SetComment ¶ added in v0.14.0
SetComment sets a comment for the golden file. Implements fluent interface.
func (*Goldy) SetContent ¶ added in v0.11.0
SetContent sets golden file content. If the golden file was a template, it expects a template string. Implements fluent interface.
func (*Goldy) String ¶ added in v0.7.0
String implements fmt.Stringer and returns golden file content.