mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-10 08:20:59 +00:00
Add tests
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"regexp"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestGetModuleCurrentVersion(t *testing.T) {
|
||||
func TestList(t *testing.T) {
|
||||
pwd, err := os.Getwd()
|
||||
if err != nil {
|
||||
t.Errorf(err.Error())
|
||||
@@ -27,3 +28,43 @@ func TestGetModuleCurrentVersion(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestRelease(t *testing.T) {
|
||||
prepareGit()
|
||||
modName := "api"
|
||||
versionType := "patch"
|
||||
pwd, err := os.Getwd()
|
||||
if err != nil {
|
||||
t.Errorf(err.Error())
|
||||
}
|
||||
remote := "upstream"
|
||||
// Check remotes
|
||||
checkRemoteExistence(pwd, remote)
|
||||
// Fetch latest tags from remote
|
||||
fetchTags(pwd, remote)
|
||||
mod := module{
|
||||
name: modName,
|
||||
path: pwd,
|
||||
}
|
||||
mod.UpdateCurrentVersion()
|
||||
|
||||
oldVersion := mod.version.String()
|
||||
mod.version.Bump(versionType)
|
||||
newVersion := mod.version.String()
|
||||
logInfo("Bumping version: %s => %s", oldVersion, newVersion)
|
||||
|
||||
// Create branch
|
||||
branch := fmt.Sprintf("release-%s-v%d.%d", mod.name, mod.version.major, mod.version.minor)
|
||||
newBranch(pwd, branch)
|
||||
|
||||
addWorktree(pwd, tempDir, branch)
|
||||
|
||||
merge(tempDir, "upstream/master")
|
||||
// Update module path
|
||||
mod.path = tempDir
|
||||
|
||||
// Clean
|
||||
cleanGit()
|
||||
pruneWorktree(pwd)
|
||||
deleteBranch(pwd, branch)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user