tests

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2023 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExpectComment

func ExpectComment(t *testing.T, identifier, comment string, file io.Reader)

ExpectComment verifies that the comment for the specified identifier in the provided file matches the expected comment. If the comments do not match, ExpectComment will fail the test with a detailed diff of the expected and found comments.

func ExpectFindings

func ExpectFindings(t *testing.T, want, got find.Findings)

ExpectFindings tests if two find.Findings are equal. It sorts the findings by identifier, then compares the sorted findings using go-cmp/cmp.

func ExpectGenerations

func ExpectGenerations(t *testing.T, want, got []generate.Generation)

ExpectGenerations compares two slices of generate.Generation and fails the test if they are not equal.

func ExpectPatch

func ExpectPatch(t *testing.T, want *patch.Patch, got *patch.Patch)

ExpectPatch compares two *patch.Patch structs and fails the test if their DryRun output differs.

func InitRepo

func InitRepo(name, root string) error

InitRepo initializes a new Git repository in the given directory and populates it with files from a fixture. The name of the fixture is passed as the first argument and must match one of the available fixtures. The second argument is the path to the directory where the repository should be created.

func Must

func Must[T any](v T, err error) T

Must is a function that takes a value and an error and returns the value. If the error is not nil, Must panics with the error. It is commonly used to simplify error handling by eliminating the need to check for errors explicitly.

func WithRepo

func WithRepo(name string, root string, fn func(fs.FS))

WithRepo initializes a new Git repository with test fixtures and executes a function on the created repository. The repository is created in the directory specified by root. The name parameter specifies which set of test fixtures to use. The function fn is called with an fs.FS that represents the root directory of the created repository.

Types

This section is empty.

Jump to

Keyboard shortcuts

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