testutils

package
v0.0.0-...-c3373f0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2024 License: Apache-2.0, MIT Imports: 14 Imported by: 0

Documentation

Overview

Package testutils provides a set of helper functions for testing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertError

func AssertError(t *testing.T, err error, isExpected bool, expectedErr string) bool

AssertError asserts the state of an error.

If isExpected is true, the function will assert that the error is not nil. If expectedErr is not empty, the function will assert that the error message matches the expected error message. If isExpected is false, the function will assert that the error is nil. The function returns true if an error was found, false otherwise.

func NewNoopLogger

func NewNoopLogger() *slog.Logger

NewNoopLogger creates a new logger that discards all logs.

func SetupFS

func SetupFS(t *testing.T, fs afero.Fs, files map[string]string)

SetupFS sets up the filesystem with the given files.

Types

type InMemRepo

type InMemRepo struct {
	Fs       billy.Filesystem
	Repo     *git.Repository
	Worktree *git.Worktree
}

InMemRepo represents an in-memory git repository.

func NewInMemRepo

func NewInMemRepo(t *testing.T) InMemRepo

NewInMemRepo creates a new in-memory git repository.

func (*InMemRepo) AddFile

func (r *InMemRepo) AddFile(t *testing.T, path, content string)

AddFile creates a file in the repository and adds it to the worktree.

func (*InMemRepo) Commit

func (r *InMemRepo) Commit(t *testing.T, message string) plumbing.Hash

Commit creates a commit in the repository.

func (*InMemRepo) Tag

func (r *InMemRepo) Tag(t *testing.T, commit plumbing.Hash, name, message string) *plumbing.Reference

Tag creates a tag in the repository.

Jump to

Keyboard shortcuts

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