Documentation
¶
Index ¶
- Constants
- func CommitFileAndGetHash(t *testing.T, repoPath, filename, fileContent, commitMessage string) string
- func CreateKaeterModule(t *testing.T, testFolder string, module *KaeterModuleConfig) (moduleFolder, commitHash string)
- func CreateKaeterRepo(t *testing.T, module *KaeterModuleConfig) (repoMockPath, keaterModuleCommitHash string)
- func CreateMockFile(t *testing.T, tmpPath, filename, content string)
- func CreateMockFolder(t *testing.T, tmpPath, folderPath string) string
- func CreateMockRepo(t *testing.T) (folder, commitHash string)
- func CreateTmpFolder(t *testing.T) string
- func GetEmptyVersionsYaml(t *testing.T, moduleID string) string
- func SwitchToNewBranch(t *testing.T, repoPath, branchName string)
- type KaeterModuleConfig
Constants ¶
const EmptyMakefileContent = ".PHONY: build test snapshot release"
EmptyMakefileContent is the content of the minimal Makefile, used for testing
const EmptyVersionsAlternateYAML = `id: ch.open.kaeter:unit-testing
type: Makefile
versioning: SemVer
versions:
0.0.0: 1970-01-01T00:00:00Z|INIT`
EmptyVersionsAlternateYAML is a minimal kaeter versions file content with a differen module id
const EmptyVersionsGoWorkDepYAML = `` /* 133-byte string literal not displayed */
EmptyVersionsGoWorkDepYAML is the content of a minimal kaeter versions file with a declared dependency on go.work, useful for dependency related tests
const EmptyVersionsYAML = `id: ch.open.kaeter:unit-test
type: Makefile
versioning: SemVer
versions:
0.0.0: 1970-01-01T00:00:00Z|INIT`
EmptyVersionsYAML is the content of a minimal kaeter versions file, used for testing
const PendingAutoreleaseVersionsYAML = `` /* 149-byte string literal not displayed */
PendingAutoreleaseVersionsYAML is the content of a minimal kaeter versions file with a 1.0.0 AUTORELEASE pending.
const TouchMakefileContent = ".PHONY: build test release\nbuild:\n\ttouch build\ntest:\n\ttouch test\nrelease:\n\ttouch release"
TouchMakefileContent is a makefile useful for testing releases and such each target will simply touch a file matching the target name allowing easily checking from the outside if targets were called or not.
Variables ¶
This section is empty.
Functions ¶
func CommitFileAndGetHash ¶
func CommitFileAndGetHash(t *testing.T, repoPath, filename, fileContent, commitMessage string) string
CommitFileAndGetHash wrapper around git add and git commit, returns the hash of commit.
func CreateKaeterModule ¶
func CreateKaeterModule(t *testing.T, testFolder string, module *KaeterModuleConfig) (moduleFolder, commitHash string)
CreateKaeterModule is a test helper to initialize a mock kaeter module in an existing folder a KaeterModuleConfig config is used to decide how and which files to initialize
func CreateKaeterRepo ¶
func CreateKaeterRepo(t *testing.T, module *KaeterModuleConfig) (repoMockPath, keaterModuleCommitHash string)
CreateKaeterRepo is a test helper to create a mock kaeter module in a tmp fodler it returns the path to the tmp folder. Caller is responsible for deleting it.
func CreateMockFile ¶
CreateMockFile creates file with content in a tmp folder
func CreateMockFolder ¶
CreateMockFolder mock folder or folder structure in a given tmp folder returns the absolute path of created folder
func CreateMockRepo ¶
CreateMockRepo initializes a mock git repository in a tmp folder Note that it will also reset viper set the repoRoot key to the test folder as a convenience
func CreateTmpFolder ¶
CreateTmpFolder returns path to new temp folder for testing
func GetEmptyVersionsYaml ¶
GetEmptyVersionsYaml generates a new empty versions yaml with the given moduleID useful to create multiple modules without having duplicate ids.
func SwitchToNewBranch ¶
SwitchToNewBranch wrapper around git switch -c branchName
Types ¶
type KaeterModuleConfig ¶
type KaeterModuleConfig struct {
Path string // Sub folder of module relative to root folder, if empty module is created at root
CHANGELOG string
CHANGELOGCreateEmpty bool // If true create empty file, otherwise when VersionsYAML is "" file wont be created
CHANGELOGName string // Handy to create a CHANGELOG.md or CHANGE or something.spec changelog (default CHANGELOG.md)
Makefile string
MakefileCreateEmpty bool
MakefileDotKaeter bool // Create a Makefile.kaeter or plain Makefile
OverrideCommitMessage string // If not empty use this as commit message when adding files
README string
READMECreateEmpty bool
VersionsYAML string
VersionsYAMLCreateEmpty bool
}
KaeterModuleConfig configures how to create a kaeter mock