mirror of
https://git.vectorsigma.ru/public/atlantis.git
synced 2026-08-05 01:18:33 +00:00
improve error log and add unit test (needed to force push to change committing user) (#4177)
This commit is contained in:
@@ -58,8 +58,8 @@ func (p *DefaultPendingPlanFinder) findWithAbsPaths(pullDir string) ([]PendingPl
|
||||
lsCmd.Dir = repoDir
|
||||
lsOut, err := lsCmd.CombinedOutput()
|
||||
if err != nil {
|
||||
return nil, nil, errors.Wrapf(err, "running git ls-files . "+
|
||||
"--others: %s", string(lsOut))
|
||||
return nil, nil, errors.Wrapf(err, "running 'git ls-files . --others' in '%s' directory: %s",
|
||||
repoDir, string(lsOut))
|
||||
}
|
||||
for _, file := range strings.Split(string(lsOut), "\n") {
|
||||
if filepath.Ext(file) == ".tfplan" {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package events_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
@@ -18,6 +19,28 @@ func TestPendingPlanFinder_FindNoDir(t *testing.T) {
|
||||
ErrEquals(t, "open /doesntexist: no such file or directory", err)
|
||||
}
|
||||
|
||||
// If one of the dir in PR dir is not git dir then it should throw an error.
|
||||
func TestPendingPlanFinder_FindIncludingNotGitDir(t *testing.T) {
|
||||
gitDirName := ".default"
|
||||
notGitDirName := ".terragrunt-cache"
|
||||
tmpDir := DirStructure(t, map[string]interface{}{
|
||||
gitDirName: map[string]interface{}{
|
||||
"default.tfplan": nil,
|
||||
},
|
||||
notGitDirName: map[string]interface{}{
|
||||
"some_file.tfplan": nil,
|
||||
},
|
||||
})
|
||||
// Initialize git in 'default' directory
|
||||
gitDir := filepath.Join(tmpDir, gitDirName)
|
||||
runCmd(t, gitDir, "git", "init")
|
||||
pf := &events.DefaultPendingPlanFinder{}
|
||||
|
||||
_, err := pf.Find(tmpDir)
|
||||
ErrEquals(t, fmt.Sprintf("running 'git ls-files . --others' in '%s/%s' directory: fatal: "+
|
||||
"not a git repository (or any of the parent directories): .git\n: exit status 128", tmpDir, notGitDirName), err)
|
||||
}
|
||||
|
||||
// Test different directory structures.
|
||||
func TestPendingPlanFinder_Find(t *testing.T) {
|
||||
cases := []struct {
|
||||
|
||||
Reference in New Issue
Block a user