Documentation
¶
Index ¶
Examples ¶
Constants ¶
View Source
const Marker = "---\n"
Marker denotes a separator between a comment and the content in a golden test file.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Goldy ¶ added in v0.7.0
type Goldy struct {
Path string // Path to the golden file.
Comment string // Golden file comment.
Content []byte // Golden file content after the marker.
// contains filtered or unexported fields
}
Goldy represents golden file.
func New ¶ added in v0.7.0
New returns new instance of Goldy.
Example ¶
package main
import (
"fmt"
"github.com/ctx42/testing/internal/core"
"github.com/ctx42/testing/pkg/goldy"
)
func main() {
tspy := core.NewSpy()
content := goldy.Open(tspy, "testdata/text_case1.gld")
fmt.Println(content)
}
Output: Content #1. Content #2.
func Open ¶ added in v0.7.0
Open instantiates [Golden] based on the provided path to the golden file. The contents start after the mandatory Marker line, anything before it is ignored. It's customary to have short documentation about golden file contents before the marker.
func (*Goldy) Save ¶ added in v0.7.0
func (gld *Goldy) Save()
Save saves the golden file to the [Goldy.Path].
func (*Goldy) String ¶ added in v0.7.0
String implements fmt.Stringer interface and returns golden file content as string.
Click to show internal directories.
Click to hide internal directories.