fix(integration-test): use a snapshot database for Docker mode (#352)

* fix(integration): add a binary name

The first argument is used for the program name. --skip-update was
ignored.

* fix(integration): use a snapshot database

After a new vulnerability is found, this test fails

* chore(integration): add t.Run
This commit is contained in:
Teppei Fukuda
2019-12-30 17:48:15 +02:00
committed by GitHub
parent 7abd41609f
commit 0b96d08877

View File

@@ -38,6 +38,11 @@ func TestRun_WithDockerEngine(t *testing.T) {
} }
for _, tc := range testCases { for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
// Copy DB file
cacheDir := gunzipDB()
defer os.RemoveAll(cacheDir)
ctx := context.Background() ctx := context.Background()
defer ctx.Done() defer ctx.Done()
@@ -63,18 +68,13 @@ func TestRun_WithDockerEngine(t *testing.T) {
require.NoError(t, err, tc.name) require.NoError(t, err, tc.name)
} }
// run trivy of, err := ioutil.TempFile("", "integration-docker-engine-output-file-*")
tmpDir, err := ioutil.TempDir("", "integration-docker-engine-*")
require.NoError(t, err)
defer func() {
os.RemoveAll(tmpDir)
}()
of, err := ioutil.TempFile(tmpDir, "integration-docker-engine-output-file-*")
require.NoError(t, err, tc.name) require.NoError(t, err, tc.name)
app := internal.NewApp("dev") defer os.Remove(of.Name())
trivyArgs := []string{"--skip-update", "--quiet", "--cache-dir", tmpDir, "--format=json"} // run trivy
app := internal.NewApp("dev")
trivyArgs := []string{"trivy", "--skip-update", "--cache-dir", cacheDir, "--format=json"}
if !tc.invalidImage { if !tc.invalidImage {
trivyArgs = append(trivyArgs, "--output", of.Name()) trivyArgs = append(trivyArgs, "--output", of.Name())
} }
@@ -103,5 +103,6 @@ func TestRun_WithDockerEngine(t *testing.T) {
}) })
assert.NoError(t, err, tc.name) assert.NoError(t, err, tc.name)
} }
})
} }
} }