-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix same branch name different sources (#222)
* add TestMultipleSourcesWithSameBrancheName and use absolute path for purgeUnmanagedContent, fixes #220 * use absolute path including basedir for helper struct allEnvironments, fixes #220 * use absolute path for purgeUnmanagedContent, fixes #220 * remove too verbose env output * fix TestResolvePuppetfileUseSSHAgent by adding a test fake key
- Loading branch information
Showing
8 changed files
with
126 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2153,14 +2153,14 @@ func TestPurgeStaleDeploymentOnly(t *testing.T) { | |
|
||
expectedLines := []string{ | ||
"DEBUG purgeUnmanagedContent(): Glob'ing with path /tmp/full/full_*", | ||
"DEBUG purgeUnmanagedContent(): Checking if environment should exist: full_another", | ||
"DEBUG purgeUnmanagedContent(): Not purging environment full_another", | ||
"DEBUG purgeUnmanagedContent(): Checking if environment should exist: full_master", | ||
"DEBUG purgeUnmanagedContent(): Not purging environment full_master", | ||
"DEBUG purgeUnmanagedContent(): Checking if environment should exist: full_qa", | ||
"DEBUG purgeUnmanagedContent(): Not purging environment full_qa", | ||
"DEBUG purgeUnmanagedContent(): Checking if environment should exist: full_stale", | ||
"Removing unmanaged environment full_stale", | ||
"DEBUG purgeUnmanagedContent(): Checking if environment should exist: /tmp/full/full_another", | ||
"DEBUG purgeUnmanagedContent(): Not purging environment /tmp/full/full_another", | ||
"DEBUG purgeUnmanagedContent(): Checking if environment should exist: /tmp/full/full_master", | ||
"DEBUG purgeUnmanagedContent(): Not purging environment /tmp/full/full_master", | ||
"DEBUG purgeUnmanagedContent(): Checking if environment should exist: /tmp/full/full_qa", | ||
"DEBUG purgeUnmanagedContent(): Not purging environment /tmp/full/full_qa", | ||
"DEBUG purgeUnmanagedContent(): Checking if environment should exist: /tmp/full/full_stale", | ||
"Removing unmanaged environment /tmp/full/full_stale", | ||
} | ||
|
||
for _, expectedLine := range expectedLines { | ||
|
@@ -2221,14 +2221,14 @@ func TestPurgeStaleDeploymentOnlyWithAllowList(t *testing.T) { | |
|
||
expectedLines := []string{ | ||
"DEBUG purgeUnmanagedContent(): Glob'ing with path /tmp/full/full_*", | ||
"DEBUG purgeUnmanagedContent(): Checking if environment should exist: full_another", | ||
"DEBUG purgeUnmanagedContent(): Not purging environment full_another", | ||
"DEBUG purgeUnmanagedContent(): Checking if environment should exist: full_master", | ||
"DEBUG purgeUnmanagedContent(): Not purging environment full_master", | ||
"DEBUG purgeUnmanagedContent(): Checking if environment should exist: full_qa", | ||
"DEBUG purgeUnmanagedContent(): Not purging environment full_qa", | ||
"DEBUG purgeUnmanagedContent(): Checking if environment should exist: full_stale", | ||
"Removing unmanaged environment full_stale", | ||
"DEBUG purgeUnmanagedContent(): Checking if environment should exist: /tmp/full/full_another", | ||
"DEBUG purgeUnmanagedContent(): Not purging environment /tmp/full/full_another", | ||
"DEBUG purgeUnmanagedContent(): Checking if environment should exist: /tmp/full/full_master", | ||
"DEBUG purgeUnmanagedContent(): Not purging environment /tmp/full/full_master", | ||
"DEBUG purgeUnmanagedContent(): Checking if environment should exist: /tmp/full/full_qa", | ||
"DEBUG purgeUnmanagedContent(): Not purging environment /tmp/full/full_qa", | ||
"DEBUG purgeUnmanagedContent(): Checking if environment should exist: /tmp/full/full_stale", | ||
"Removing unmanaged environment /tmp/full/full_stale", | ||
} | ||
|
||
for _, expectedLine := range expectedLines { | ||
|
@@ -2882,7 +2882,7 @@ func TestResolvePuppetfileUseSSHAgent(t *testing.T) { | |
if exitCode != 1 { | ||
t.Errorf("terminated with %v, but we expected exit status %v Output: %s", exitCode, 1, string(out)) | ||
} | ||
//fmt.Println(string(out)) | ||
// fmt.Println(string(out)) | ||
|
||
sshAddCmd := "ssh-add" | ||
if runtime.GOOS == "darwin" { | ||
|
@@ -2891,11 +2891,11 @@ func TestResolvePuppetfileUseSSHAgent(t *testing.T) { | |
|
||
expectedLines := []string{ | ||
"DEBUG git repo url [email protected]:foo/git_module_with_ssh_agent.git with loaded SSH keys from ssh-agent", | ||
"DEBUG git repo url [email protected]:foobar/github_module_without_ssh_add.git with SSH key tests/TestConfigUseSSHAgent.yaml", | ||
"DEBUG git repo url [email protected]:bar/git_module_with_ssh_add.git with SSH key tests/TestConfigUseSSHAgent.yaml", | ||
"DEBUG git repo url [email protected]:foobar/github_module_without_ssh_add.git with SSH key tests/test-fake-key", | ||
"DEBUG git repo url [email protected]:bar/git_module_with_ssh_add.git with SSH key tests/test-fake-key", | ||
"DEBUG executeCommand(): Executing git clone --mirror [email protected]:foo/git_module_with_ssh_agent.git /tmp/g10k/modules/[email protected]_git_module_with_ssh_agent.git", | ||
"DEBUG executeCommand(): Executing git clone --mirror [email protected]:foobar/github_module_without_ssh_add.git /tmp/g10k/modules/[email protected]_github_module_without_ssh_add.git", | ||
"DEBUG executeCommand(): Executing ssh-agent bash -c '" + sshAddCmd + " tests/TestConfigUseSSHAgent.yaml; git clone --mirror [email protected]:bar/git_module_with_ssh_add.git /tmp/g10k/modules/[email protected]_git_module_with_ssh_add.git'", | ||
"DEBUG executeCommand(): Executing ssh-agent bash -c '" + sshAddCmd + " tests/test-fake-key; git clone --mirror [email protected]:bar/git_module_with_ssh_add.git /tmp/g10k/modules/[email protected]_git_module_with_ssh_add.git'", | ||
} | ||
|
||
for _, expectedLine := range expectedLines { | ||
|
@@ -3262,3 +3262,46 @@ func TestNoProxy(t *testing.T) { | |
} | ||
} | ||
} | ||
|
||
func TestMultipleSourcesWithSameBrancheName(t *testing.T) { | ||
funcName := strings.Split(funcName(), ".")[len(strings.Split(funcName(), "."))-1] | ||
config = readConfigfile(filepath.Join("tests", "TestConfig2SourcesSameBranchNameDiffBaseDir.yaml")) | ||
if os.Getenv("TEST_FOR_CRASH_"+funcName) == "1" { | ||
debug = true | ||
info = true | ||
resolvePuppetEnvironment(false, "") | ||
return | ||
} | ||
purgeDir("/tmp/example/", funcName) | ||
purgeDir("/tmp/out/", funcName) | ||
purgeDir("/tmp/out-clone/", funcName) | ||
|
||
cmd := exec.Command(os.Args[0], "-test.run="+funcName+"$") | ||
cmd.Env = append(os.Environ(), "TEST_FOR_CRASH_"+funcName+"=1") | ||
_, err := cmd.CombinedOutput() | ||
|
||
exitCode := 0 | ||
if msg, ok := err.(*exec.ExitError); ok { // there is error code | ||
exitCode = msg.Sys().(syscall.WaitStatus).ExitStatus() | ||
} | ||
|
||
expectedExitCode := 0 | ||
if exitCode != expectedExitCode { | ||
t.Errorf("terminated with %v, but we expected exit status %v", exitCode, expectedExitCode) | ||
} | ||
// fmt.Println(string(out)) | ||
|
||
expectedFiles := []string{ | ||
"/tmp/out-clone/another/Puppetfile", | ||
"/tmp/out-clone/master/.g10k-deploy.json", | ||
"/tmp/out/master/Puppetfile", | ||
"/tmp/out/ref/uuui/d0", | ||
} | ||
|
||
for _, expectedFile := range expectedFiles { | ||
if !fileExists(expectedFile) { | ||
t.Errorf("files and/or directory missing that should be there! " + expectedFile) | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
cachedir: '/tmp/g10k' | ||
|
||
sources: | ||
example: | ||
remote: 'https://github.com/xorpaul/g10k-fullworking-env-clone.git' | ||
basedir: '/tmp/out/' | ||
full: | ||
remote: 'https://github.com/xorpaul/g10k-fullworking-env.git' | ||
basedir: '/tmp/out-clone/' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
--- | ||
:cachedir: '/tmp/g10k' | ||
:cachedir: "/tmp/g10k" | ||
|
||
sources: | ||
example: | ||
remote: 'https://github.com/xorpaul/g10k-environment.git' | ||
basedir: '/tmp/example/' | ||
private_key: 'tests/TestConfigUseSSHAgent.yaml' # just some existing file, we just want to check if the ssh-add command isn't used | ||
remote: "https://github.com/xorpaul/g10k-environment.git" | ||
basedir: "/tmp/example/" | ||
private_key: "tests/test-fake-key" # just some existing file, we just want to check if the ssh-add command isn't used |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
-----BEGIN OPENSSH PRIVATE KEY----- | ||
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABlwAAAAdzc2gtcn | ||
NhAAAAAwEAAQAAAYEA2Bk3OVSuVcP0Wdw57JzKMxKbf3qwBPHZHrMN8MJ7S/qZ11zAUzAY | ||
57Y4e6sE8dd+nC1hK2E8vBZcyib/W+mWJw3JzUHsGTJgZCi+kRieXwZmztwNC4+sUDwDf6 | ||
lT8K95kXV36r5IYoo16Fh5/yxYON+HBtDAYDIZp01ez5VDhjNMpnUX39Km5Jt9950CdkhN | ||
pns66QYPAZ3sKBhwGt7l7+X15aKxNaVshLJtPd4V21hDbyqyQUJOwRjj6R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