Documentation ¶
Index ¶
- Constants
- Variables
- 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" DatasetMerged = "datasetmerged" DiffOutput = "diff_output" UpdateMergeConflict = "updateMergeConflict" )
const TmpDirPrefix = "test-kpt"
Variables ¶
var AssertNoError = assertnow.NilError
var KptfileSet = func() sets.String { s := sets.String{} s.Insert(kptfile.KptFileName) return s }()
Functions ¶
This section is empty.
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