Skip to content
This repository was archived by the owner on Mar 27, 2024. It is now read-only.

Commit 9405a2c

Browse files
committed
Run tests in parallel, dont use working dir
This changes the CloudPrepper to not store intermediate artifacts in the current directory, allowing the tests to be ran in parallel.
1 parent f024fad commit 9405a2c

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

tests/integration_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ func TestDiffAndAnalysis(t *testing.T) {
162162
}
163163
for _, test := range tests {
164164
t.Run(test.description, func(t *testing.T) {
165+
t.Parallel()
165166
args := []string{test.subcommand, test.imageA}
166167
if test.imageB != "" {
167168
args = append(args, test.imageB)

utils/image_prep_utils.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,13 @@ func (p CloudPrepper) getFileSystem() (string, error) {
128128
URLPattern := regexp.MustCompile("^.+/(.+(:.+){0,1})$")
129129
URLMatch := URLPattern.FindStringSubmatch(p.Source)
130130
// Removing the ":" so that the image path name can be <image><tag>
131-
path := strings.Replace(URLMatch[1], ":", "", -1)
131+
sanitizedName := strings.Replace(URLMatch[1], ":", "", -1)
132+
133+
path, err := ioutil.TempDir("", sanitizedName)
134+
if err != nil {
135+
return "", err
136+
}
137+
132138
ref, err := docker.ParseReference("//" + p.Source)
133139
if err != nil {
134140
return "", err
@@ -156,10 +162,6 @@ func (p CloudPrepper) getFileSystem() (string, error) {
156162
return "", err
157163
}
158164

159-
if _, ok := os.Stat(path); ok != nil {
160-
os.MkdirAll(path, 0777)
161-
}
162-
163165
for _, b := range img.LayerInfos() {
164166
bi, _, err := imgSrc.GetBlob(b)
165167
if err != nil {

0 commit comments

Comments
 (0)