Documentation ¶
Index ¶
- Constants
- Variables
- func AssertEqual(t *testing.T, g *TestGitRepo, sourceDir, destDir string)
- func Commit(t *testing.T, g *TestGitRepo, message string)
- func CommitTag(t *testing.T, g *TestGitRepo, tag string)
- func Compare(t *testing.T, a, b string)
- func CopyData(t *testing.T, g *TestGitRepo, data, dest string)
- func CopyKptfile(t *testing.T, src, dest string)
- func Diff(sourceDir, destDir string) (sets.String, error)
- func GetTestDataPath() (string, error)
- func RemoveData(t *testing.T, g *TestGitRepo)
- func Replace(t *testing.T, path, old, new string)
- func Tag(t *testing.T, g *TestGitRepo, tag string)
- type TestGitRepo
- func (g *TestGitRepo) AssertEqual(t *testing.T, sourceDir, destDir string) bool
- func (g *TestGitRepo) AssertKptfile(t *testing.T, cloned string, kpkg kptfile.KptFile) bool
- func (g *TestGitRepo) CheckoutBranch(branch string, create bool) error
- func (g *TestGitRepo) Commit(message string) error
- func (g *TestGitRepo) CopyAddData(data string) error
- func (g *TestGitRepo) GetCommit() (string, error)
- func (g *TestGitRepo) RemoveAll() error
- func (g *TestGitRepo) ReplaceData(data string) error
- func (g *TestGitRepo) SetupTestGitRepo(data string) error
- func (g *TestGitRepo) Tag(tag string) error
Constants ¶
const ( Dataset1 = "dataset1" Dataset2 = "dataset2" Dataset3 = "dataset3" Dataset4 = "dataset4" // Dataset4 is replica of Dataset2 with different setter values Dataset5 = "dataset5" // Dataset5 is replica of Dataset2 with additional non KRM files DatasetMerged = "datasetmerged" DiffOutput = "diff_output" UpdateMergeConflict = "updateMergeConflict" HelloWorldSet = "helloworld-set" HelloWorldFn = "helloworld-fn" HelloWorldFnNoKptfile = "helloworld-fn-no-kptfile" )
const TmpDirPrefix = "test-kpt"
Variables ¶
var AssertNoError = assertnow.NilError
var KptfileSet = func() sets.String { s := sets.String{} s.Insert(kptfile.KptFileName) return s }()
Functions ¶
func AssertEqual ¶ added in v0.18.0
func AssertEqual(t *testing.T, g *TestGitRepo, sourceDir, destDir string)
func CopyKptfile ¶ added in v0.18.0
func Diff ¶ added in v0.26.0
Diff returns a list of files that differ between the source and destination.
Diff is guaranteed to return a non-empty set if any files differ, but this set is not guaranteed to contain all differing files.
func GetTestDataPath ¶ added in v0.18.0
func RemoveData ¶ added in v0.18.0
func RemoveData(t *testing.T, g *TestGitRepo)
Types ¶
type TestGitRepo ¶
type TestGitRepo struct { // RepoDirectory is the temp directory of the git repo RepoDirectory string // DatasetDirectory is the directory of the testdata files DatasetDirectory string // RepoName is the name of the repository RepoName string Updater string }
TestGitRepo manages a local git repository for testing
func SetupDefaultRepoAndWorkspace ¶
func SetupDefaultRepoAndWorkspace(t *testing.T) (*TestGitRepo, string, func())
SetupDefaultRepoAndWorkspace handles setting up a default repo to clone, and a workspace to clone into. returns a cleanup function to remove the git repo and workspace.
func (*TestGitRepo) AssertEqual ¶
func (g *TestGitRepo) AssertEqual(t *testing.T, sourceDir, destDir string) bool
AssertEqual verifies the contents of a source package matches the contents of the destination package it was fetched to. Excludes comparing the .git directory in the source package.
While the sourceDir can be the TestGitRepo, because tests change the TestGitRepo may have been changed after the destDir was copied, it is often better to explicitly use a set of golden files as the sourceDir rather than the original TestGitRepo that was copied.
func (*TestGitRepo) AssertKptfile ¶
AssertKptfile verifies the contents of the KptFile matches the provided value.
func (*TestGitRepo) CheckoutBranch ¶
func (g *TestGitRepo) CheckoutBranch(branch string, create bool) error
CheckoutBranch checks out the git branch in the repo
func (*TestGitRepo) Commit ¶
func (g *TestGitRepo) Commit(message string) error
Commit performs a git commit
func (*TestGitRepo) CopyAddData ¶
func (g *TestGitRepo) CopyAddData(data string) error
CopyAddData copies data from a source and adds it
func (*TestGitRepo) GetCommit ¶
func (g *TestGitRepo) GetCommit() (string, error)
func (*TestGitRepo) RemoveAll ¶
func (g *TestGitRepo) RemoveAll() error
RemoveAll deletes the test git repo
func (*TestGitRepo) ReplaceData ¶
func (g *TestGitRepo) ReplaceData(data string) error
ReplaceData replaces the data with a new source
func (*TestGitRepo) SetupTestGitRepo ¶
func (g *TestGitRepo) SetupTestGitRepo(data string) error
SetupTestGitRepo initializes a new git repository and populates it with data from a source
func (*TestGitRepo) Tag ¶
func (g *TestGitRepo) Tag(tag string) error
Tag initializes tags the git repository