testutil

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2025 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BranchRefName

func BranchRefName(branch string) string

func CheckoutBranch

func CheckoutBranch(g *WithT, repo *extgogit.Repository, branch string)

func Clone

func Clone(ctx context.Context, repoURL, branchName, remote string) (*extgogit.Repository, string, error)

func CommitIdFromBranch

func CommitIdFromBranch(repo *extgogit.Repository, branchName string) string

func CommitInRepo

func CommitInRepo(ctx context.Context, g *WithT, repoURL, branch, remote, msg string, changeFiles func(path string)) plumbing.Hash

func CommitWorkDir

func CommitWorkDir(g *WithT, repo *extgogit.Repository, branchName, message string) plumbing.Hash

func ExpectMatchingDirectories added in v1.0.0

func ExpectMatchingDirectories(g *WithT, actualRoot, expectedRoot string)

ExpectMatchingDirectories compares two directories, recursively, and expects them to match. It will fail if there are files that are present in one directory but not the other, or if files that are present in both directories have different contents.

func GetRemoteHead

func GetRemoteHead(repo *extgogit.Repository, branchName, remote string) (plumbing.Hash, error)

func GetSigningKeyPair

func GetSigningKeyPair(g *WithT, passphrase string) (*openpgp.Entity, []byte)

func GetSigningKeyPairSecret

func GetSigningKeyPairSecret(g *WithT, name, namespace string) (*corev1.Secret, *openpgp.Entity)

func HeadFromBranch

func HeadFromBranch(repo *extgogit.Repository, branchName string) (*object.Commit, error)

func ImageToRef added in v0.41.0

func ImageToRef(image string) *reflectorv1.ImageRef

func InitGitRepo

func InitGitRepo(g *WithT, gitServer *gittestserver.GitServer, fixture, branch, repoPath string) *extgogit.Repository

Initialise a git server with a repo including the files in dir.

func InitGitRepoPlain

func InitGitRepoPlain(g *WithT, fixture, repoPath string) *extgogit.Repository

func ReplaceMarker

func ReplaceMarker(path string, policyKey types.NamespacedName) error

func ReplaceMarkerWithMarker

func ReplaceMarkerWithMarker(path string, policyKey types.NamespacedName, marker string) error

func SetUpGitTestServer

func SetUpGitTestServer(g *WithT) *gittestserver.GitServer

SetUpGitTestServer creates and returns a git test server. The caller must ensure it's stopped and cleaned up.

func TagCommit

func TagCommit(g *WithT, repo *extgogit.Repository, commit plumbing.Hash, annotated bool, tag string, time time.Time) (*plumbing.Reference, error)

func WaitForNewHead

func WaitForNewHead(g *WithT, repo *extgogit.Repository, branch, remote, preChangeHash string)

Types

type Diff added in v1.0.0

type Diff interface {
	Path() string
	FailedExpectation(g *WithT)
}

func DiffDirectories added in v1.0.0

func DiffDirectories(actual, expected string) (actualonly []string, expectedonly []string, different []Diff)

DiffDirectories walks the two given directories, recursively, and reports relative paths for any files that are:

(in actual but not expected, in expected but not actual, in both but different)

It ignores dot directories (e.g., `.git/`) and Emacs backups (e.g., `foo.yaml~`). It panics if it encounters any error apart from a file not found.

Jump to

Keyboard shortcuts

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