Files
trivy/pkg/db/db_mock.go
Teppei Fukuda ff873a274b Support Amazon Linux (#182)
* Support Amazon Linux

* amazon: Add tests for Scanner Detect functionality

* amazon: Add more test cases for unhappy paths.

This commit also asserts the logged output via observer.

Signed-off-by: Simarpreet Singh <simar@linux.com>

* amazon: Add a test case for invalid fixed pkg version

Signed-off-by: Simarpreet Singh <simar@linux.com>

* mod: go mod tidy

Signed-off-by: Simarpreet Singh <simar@linux.com>

* amazon: Inject dependency seams for exposed db interface and logger.

This commit also exposes an interface for doing db operations.

Signed-off-by: Simarpreet Singh <simar@linux.com>

* amazon: Use injected logger for scanner.

Signed-off-by: Simarpreet Singh <simar@linux.com>

* amazon_test: Add a sample testdata dir

Signed-off-by: Simarpreet Singh <simar@linux.com>

* amazon: Add tests for for Get() for amazon vulns.

Signed-off-by: Simarpreet Singh <simar@linux.com>

* vulnsrc_test: Fix invocation call to SetVersion()

Signed-off-by: Simarpreet Singh <simar@linux.com>

* amazon_test: Add a test for severirtyFromPriority

Signed-off-by: Simarpreet Singh <simar@linux.com>

* amazon_test: Add tests for constructVersion()

Signed-off-by: Simarpreet Singh <simar@linux.com>

* amazon: Refactor walkFunc outside for testability purposes

Signed-off-by: Simarpreet Singh <simar@linux.com>

* amazon: Refactor walkFn and add tests for it.

Signed-off-by: Simarpreet Singh <simar@linux.com>

* amazon: Refactor commitFunc closure and add tests

This commit also introduces an interface for the
vulnerability package to be used as a seam.

Signed-off-by: Simarpreet Singh <simar@linux.com>

* Revert "amazon: Use injected logger for scanner."

This reverts commit 5a81e4d824a95f4de4aae2e2b903eedd0f7e241f.

* test(amazon): fix failed tests

* fix(vulnerability): trim references

* test(amazon): add integration test
2019-10-22 09:31:15 +03:00

44 lines
903 B
Go

package db
import (
bolt "github.com/etcd-io/bbolt"
"github.com/stretchr/testify/mock"
)
type MockDBConfig struct {
mock.Mock
}
func (_m *MockDBConfig) SetVersion(version string) error {
ret := _m.Called(version)
return ret.Error(0)
}
func (_m *MockDBConfig) Update(a, b, c string, d interface{}) error {
ret := _m.Called(a, b, c, d)
return ret.Error(0)
}
func (_m *MockDBConfig) BatchUpdate(f func(*bolt.Tx) error) error {
ret := _m.Called(f)
return ret.Error(0)
}
func (_m *MockDBConfig) PutNestedBucket(a *bolt.Tx, b, c, d string, e interface{}) error {
ret := _m.Called(a, b, c, d, e)
return ret.Error(0)
}
func (_m *MockDBConfig) ForEach(a string, b string) (map[string][]byte, error) {
ret := _m.Called(a, b)
ret0 := ret.Get(0)
if ret0 == nil {
return nil, ret.Error(1)
}
r, ok := ret0.(map[string][]byte)
if !ok {
return nil, ret.Error(1)
}
return r, ret.Error(1)
}