golden

package
v0.14.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 10, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package golden helps manage goldenfiles.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithDir

func WithDir(dir string) goldenFileOption

func WithFileName

func WithFileName(fn string) goldenFileOption

func WithSanitizer

func WithSanitizer(s Sanitizer) goldenFileOption

func WithStringSanitizer

func WithStringSanitizer(old, new string) goldenFileOption

Types

type GoldenFile

type GoldenFile struct {
	// contains filtered or unexported fields
}

func NewOrUpdate

func NewOrUpdate(t testing.TB, data string, opts ...goldenFileOption) *GoldenFile

func (*GoldenFile) ApplySanitizers

func (g *GoldenFile) ApplySanitizers(s string) string

ApplySanitizers returns sanitized string

func (*GoldenFile) GetJSON

func (g *GoldenFile) GetJSON() gjson.Result

GetJSON returns goldenfile as parsed json

func (*GoldenFile) GetName

func (g *GoldenFile) GetName() string

GetName return path of the goldenfile

func (*GoldenFile) GetSanitizedJSON

func (g *GoldenFile) GetSanitizedJSON(s gjson.Result) gjson.Result

GetSanitizedJSON returns sanitizes and returns JSON result

func (*GoldenFile) JSONEq

func (g *GoldenFile) JSONEq(a *assert.Assertions, got gjson.Result, jsonPath string)

JSONEq asserts that json content in jsonPath for got and goldenfile is the same

type Sanitizer

type Sanitizer func(string) string

func ProjectIDSanitizer

func ProjectIDSanitizer(t testing.TB) Sanitizer

ProjectIDSanitizer replaces all occurrences of current gcloud project ID with PROJECT_ID string

func StringSanitizer

func StringSanitizer(old, new string) Sanitizer

StringSanitizer replaces all occurrences of old string with new string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL