snapshot

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 6, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetNewSnapshotPaths

func GetNewSnapshotPaths() ([]string, error)

Returns all the `.snap.new` snapshots in the current directory and its sub-directories.

Types

type Snapshot

type Snapshot struct {
	Loc int

	Name    string
	Source  string
	Content string
	// contains filtered or unexported fields
}

func AcceptAll

func AcceptAll(paths []string) ([]Snapshot, error)

func Read

func Read(snapshotPath string) (Snapshot, error)

Parses a snapshot file into the `Snapshot` struct. Returns an error if `snapshotPath` doesn't exist.

func RejectAll

func RejectAll(paths []string) ([]Snapshot, error)

func Write

func Write(path, snapshotName, content, source string, loc int) (Snapshot, error)

Writes a `.snap.new` snapshot to `path`.

func (Snapshot) Accept

func (s Snapshot) Accept() error

func (Snapshot) CleanPath

func (s Snapshot) CleanPath() string

Return the snapshot path relative to the `go.mod` directory.

func (Snapshot) Diff

func (s Snapshot) Diff() string

Compute the difference between the new snapshot (.snap.new) and the old snapshot (.snap). Return the diff string.

func (Snapshot) HasDifference

func (s Snapshot) HasDifference() bool

func (Snapshot) IsNew

func (s Snapshot) IsNew() bool

func (Snapshot) Reject

func (s Snapshot) Reject()

type Summary

type Summary struct {
	Accepted []Snapshot
	Rejected []Snapshot
	Skipped  []Snapshot
}

func (*Summary) AddAccepted

func (s *Summary) AddAccepted(snapshot Snapshot)

func (*Summary) AddRejected

func (s *Summary) AddRejected(snapshot Snapshot)

func (*Summary) AddSkipped

func (s *Summary) AddSkipped(snapshot Snapshot)

Jump to

Keyboard shortcuts

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