-
Notifications
You must be signed in to change notification settings - Fork 507
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build pipeline changes and more tests
- Loading branch information
1 parent
456cb31
commit f906aed
Showing
10 changed files
with
132 additions
and
42 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
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,2 @@ | ||
[policy] | ||
path = "invalid/path" |
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,3 @@ | ||
[policy] | ||
repo_url = "https://github.com/accurics/KaiMonkey.git" | ||
branch = "master" |
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,41 @@ | ||
package init | ||
|
||
import ( | ||
"io" | ||
|
||
"github.com/accurics/terrascan/test/helper" | ||
"github.com/onsi/gomega" | ||
"github.com/onsi/gomega/gexec" | ||
"gopkg.in/src-d/go-git.v4" | ||
) | ||
|
||
const ( | ||
initCommandTimeout = 60 | ||
) | ||
|
||
// RunInitCommand will execute the init command and verify exit code | ||
func RunInitCommand(terrascanBinaryPath string, outWriter, errWriter io.Writer, exitCode int) *gexec.Session { | ||
session := helper.RunCommand(terrascanBinaryPath, outWriter, errWriter, "init") | ||
gomega.Eventually(session, initCommandTimeout).Should(gexec.Exit(exitCode)) | ||
return session | ||
} | ||
|
||
// OpenGitRepo checks if a directory is a git repo | ||
func OpenGitRepo(repoPath string) *git.Repository { | ||
repo, err := git.PlainOpen(repoPath) | ||
gomega.Expect(err).NotTo(gomega.HaveOccurred()) | ||
gomega.Expect(repo).NotTo(gomega.BeNil()) | ||
return repo | ||
} | ||
|
||
// ValidateGitRepo validates a git repo and verifies the git url | ||
func ValidateGitRepo(repo *git.Repository, gitURL string) { | ||
remote, err := repo.Remote("origin") | ||
gomega.Expect(err).NotTo(gomega.HaveOccurred()) | ||
gomega.Expect(remote).NotTo(gomega.BeNil()) | ||
remoteConfig := remote.Config() | ||
gomega.Expect(remoteConfig).NotTo(gomega.BeNil()) | ||
err = remoteConfig.Validate() | ||
gomega.Expect(err).NotTo(gomega.HaveOccurred()) | ||
gomega.Expect(remoteConfig.URLs[0]).To(gomega.BeEquivalentTo(gitURL)) | ||
} |
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,13 @@ | ||
// +build tools | ||
|
||
package tools | ||
|
||
import ( | ||
// used only for testing | ||
_ "github.com/onsi/ginkgo/ginkgo" | ||
// used only for testing | ||
_ "github.com/onsi/gomega" | ||
) | ||
|
||
// This file imports packages that are used when running go generate, or used | ||
// during the development process but not otherwise depended on by built code. |