tests

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2023 License: MIT Imports: 17 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 ExpectCommentIn added in v0.0.4

func ExpectCommentIn(t *testing.T, repo fs.FS, file, identifier, comment string)

func ExpectFiles added in v0.0.4

func ExpectFiles(t *testing.T, want, got []string)

func ExpectFindings

func ExpectFindings[Findings ~map[string][]Finding, Finding interface{ GetIdentifier() string }](t *testing.T, want, got 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 ExpectFound added in v0.0.4

func ExpectFound[Finding interface{ String() string }](t *testing.T, want, got []Finding)

func ExpectGeneratedFiles added in v0.0.4

func ExpectGeneratedFiles(t *testing.T, want, got []generate.File)

func ExpectGenerations

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

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

func ExpectIdentifiers added in v0.0.4

func ExpectIdentifiers[Finding ~string](t *testing.T, want, got []Finding)

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