Documentation ¶
Index ¶
- Constants
- Variables
- func AssertErrorMatch(t *testing.T, s string, e error)
- func AssertNoError(t *testing.T, err error)
- func MatchErrorString(t *testing.T, s string, e error) bool
- func NewGitRepository(opts ...func(*sourcev1.GitRepository)) *sourcev1.GitRepository
- func NewKustomization(gr *sourcev1.GitRepository, opts ...func(*kustomizev1.Kustomization)) *kustomizev1.Kustomization
- func NewKustomizationAutoDeployer(opts ...func(*deployerv1.KustomizationAutoDeployer)) *deployerv1.KustomizationAutoDeployer
- func UpdateRepoStatus(t *testing.T, k8sClient client.Client, repo *sourcev1.GitRepository, ...)
- type TestRepository
Constants ¶
const ( // This is the default name of the GitRepository created by // NewGitRepository. DefaultGitRepositoryName = "test-gitrepository" // This is the default name of the Kustomization created by NewKustomization. DefaultKustomizationName = "test-kustomization" // This is the default branch for the GitRepository created by // NewGitRepository. DefaultGitRepositoryBranch = "main" DefaultNamespace = "default" )
Variables ¶
var CommitIDs = []string{
"6f935147b28e38a99a700843e4893a801c3c8148",
"6b36589c98beb53b564aa2b838d8d045f0d0794d",
"d2fb242401eb5146b5935f2b8483ffe9ffcef3fd",
"ece9b0c9300f65546ca8f57d80bcd6378f051e59",
"dd587268153ad335545a53f15efee4ecfabcd1c8",
"5ed746679fd79a91517ab32b83ed68c4a315040d",
"4553f10114fd9c7e82b65d65ffa8e124911b08e6",
"e5d6eeed2f5574737ae73a33bfd208a37b50ccd8",
"848e164167cc4db24c21fc47a3da190e5bb801c1",
"d756705b4a8462d68838add62892904bcaa1a279",
"1d27b733842bb5a29a118c950f521e0ef6ee31f8",
"9574855e863316ae161c2f9512cc1203d79d59fa",
"edd180938ddfd80161f20c22fa58a2b16dfd66f3",
"039dc250bc8bd17c1b3bf5abe6bce68e338e966e",
"fa079ad89794b3ebf5932f55ced9e0a714841fac",
"d7890a3d6b262a48c126a1ebdc0e71239d33cc8c",
"6e430dd9f8fb6f1830f6d2d765e13cf9f3ddfe4a",
}
CommitIDs is just a slice of SHA1s
Functions ¶
func AssertErrorMatch ¶
AssertErrorMatch will fail if the error doesn't match the provided error.
func AssertNoError ¶
AssertNoError will fail if the provided err value is an error.
func MatchErrorString ¶
MatchErrorString takes a string and matches on the error and returns true if the string matches the error.
This is useful in table tests.
If the string can't be compiled as an regexp, then this will fail with a Fatal error.
func NewGitRepository ¶
func NewGitRepository(opts ...func(*sourcev1.GitRepository)) *sourcev1.GitRepository
NewGitRepository creates a new GitRepository.
This will use the default name
func NewKustomization ¶
func NewKustomization(gr *sourcev1.GitRepository, opts ...func(*kustomizev1.Kustomization)) *kustomizev1.Kustomization
func NewKustomizationAutoDeployer ¶
func NewKustomizationAutoDeployer(opts ...func(*deployerv1.KustomizationAutoDeployer)) *deployerv1.KustomizationAutoDeployer
NewKustomizationAutoDeployer creates and returns a new KustomizationDeployer.
func UpdateRepoStatus ¶
func UpdateRepoStatus(t *testing.T, k8sClient client.Client, repo *sourcev1.GitRepository, update func(*sourcev1.GitRepository))
UpdateRepoStatus applies changes from an update function to a GitRepository and sets the LastUpdateTime at the same time.
Types ¶
type TestRepository ¶
type TestRepository struct { Base string Dir string Repository *git.Repository // contains filtered or unexported fields }
TestRepository is a self-contained Git repository used in testing.
func NewRepository ¶
func NewRepository(t *testing.T) *TestRepository
NewRepository creates and initialises a new git repository in a temporary directory, with an initial commit with a README file.
func (*TestRepository) Head ¶
func (n *TestRepository) Head() string
Heads returns the HEAD commit ID.
func (*TestRepository) WriteFileAndCommit ¶
func (n *TestRepository) WriteFileAndCommit(filename string, body []byte) string
WriteFileAndCommit writes a file to the filesystem in a subdirectory of the temporary directory, it also commits and returns the commit ID.
func (*TestRepository) WriteValueAndTag ¶
func (n *TestRepository) WriteValueAndTag(filename string, v any) string
WriteProfileAndCommit serialises the provided value to YAML and writes it to the file.