Improve test that was sometimes passing too quickly where it should fail

This commit is contained in:
Guillaume Tardif 2020-08-05 13:59:03 +02:00
parent d1b8bcb2c7
commit 4dd1918ac2
1 changed files with 5 additions and 2 deletions

View File

@ -24,6 +24,8 @@ import (
"testing"
"time"
"github.com/docker/api/cli/mobycli"
. "github.com/onsi/gomega"
"github.com/stretchr/testify/suite"
@ -50,9 +52,10 @@ RUN sleep 100`), 0644)).To(Succeed())
_, err := ctx.Exec()
errs <- err
}()
mobyBuild := mobycli.ComDockerCli + " build --no-cache -t " + imageName
err := WaitFor(time.Second, 10*time.Second, errs, func() bool {
out := s.ListProcessesCommand().ExecOrDie()
return strings.Contains(out, imageName)
return strings.Contains(out, mobyBuild)
})
Expect(err).NotTo(HaveOccurred())
log.Println("Killing docker process")
@ -60,7 +63,7 @@ RUN sleep 100`), 0644)).To(Succeed())
close(shutdown)
err = WaitFor(time.Second, 12*time.Second, nil, func() bool {
out := s.ListProcessesCommand().ExecOrDie()
return !strings.Contains(out, imageName)
return !strings.Contains(out, mobyBuild)
})
Expect(err).NotTo(HaveOccurred())
})