diff --git a/pkg/cli/get/resources/downloader.go b/pkg/cli/get/resources/downloader.go index ae5112d4..fd5d95a8 100644 --- a/pkg/cli/get/resources/downloader.go +++ b/pkg/cli/get/resources/downloader.go @@ -5,6 +5,8 @@ import ( "github.com/opencontrol/compliance-masonry/tools/vcs" ) +//go:generate mockery -name Downloader + // Downloader is a generic interface for how to download entries. type Downloader interface { DownloadRepo(common.RemoteSource, string) error diff --git a/pkg/cli/get/resources/getter.go b/pkg/cli/get/resources/getter.go index 93f6ff57..2075a468 100644 --- a/pkg/cli/get/resources/getter.go +++ b/pkg/cli/get/resources/getter.go @@ -11,6 +11,8 @@ import ( "path/filepath" ) +//go:generate mockery -name Getter + // getAllLocalResources will get try to get the resources that are in the current "source" directory and place them // in the final "destination" workspace directory. func getAllLocalResources(source string, destination string, opencontrol common.OpenControl, getter Getter) error { diff --git a/pkg/cli/get/resources/mocks/Downloader.go b/pkg/cli/get/resources/mocks/Downloader.go index b8b65cf8..5958c5f1 100644 --- a/pkg/cli/get/resources/mocks/Downloader.go +++ b/pkg/cli/get/resources/mocks/Downloader.go @@ -1,8 +1,8 @@ +// Code generated by mockery v1.0.0. DO NOT EDIT. package mocks -import "github.com/stretchr/testify/mock" - -import "github.com/opencontrol/compliance-masonry/pkg/lib/common" +import common "github.com/opencontrol/compliance-masonry/pkg/lib/common" +import mock "github.com/stretchr/testify/mock" // Downloader is an autogenerated mock type for the Downloader type type Downloader struct { diff --git a/pkg/cli/get/resources/mocks/Getter.go b/pkg/cli/get/resources/mocks/Getter.go index ab5db221..0cde9359 100644 --- a/pkg/cli/get/resources/mocks/Getter.go +++ b/pkg/cli/get/resources/mocks/Getter.go @@ -1,23 +1,22 @@ +// Code generated by mockery v1.0.0. DO NOT EDIT. package mocks -import ( - "github.com/opencontrol/compliance-masonry/pkg/lib/common" - "github.com/opencontrol/compliance-masonry/tools/constants" - "github.com/stretchr/testify/mock" -) +import common "github.com/opencontrol/compliance-masonry/pkg/lib/common" +import constants "github.com/opencontrol/compliance-masonry/tools/constants" +import mock "github.com/stretchr/testify/mock" // Getter is an autogenerated mock type for the Getter type type Getter struct { mock.Mock } -// GetLocalResources provides a mock function with given fields: source, resources, destination, subfolder, recursively, resourceType -func (_m *Getter) GetLocalResources(source string, resources []string, destination string, subfolder string, recursively bool, resourceType constants.ResourceType) error { - ret := _m.Called(source, resources, destination, subfolder, recursively, resourceType) +// GetLocalResources provides a mock function with given fields: source, _a1, destination, subfolder, recursively, resourceType +func (_m *Getter) GetLocalResources(source string, _a1 []string, destination string, subfolder string, recursively bool, resourceType constants.ResourceType) error { + ret := _m.Called(source, _a1, destination, subfolder, recursively, resourceType) var r0 error if rf, ok := ret.Get(0).(func(string, []string, string, string, bool, constants.ResourceType) error); ok { - r0 = rf(source, resources, destination, subfolder, recursively, resourceType) + r0 = rf(source, _a1, destination, subfolder, recursively, resourceType) } else { r0 = ret.Error(0) } diff --git a/pkg/lib/common/certification.go b/pkg/lib/common/certification.go index ca107296..d3a4f3e5 100644 --- a/pkg/lib/common/certification.go +++ b/pkg/lib/common/certification.go @@ -1,5 +1,7 @@ package common +//go:generate mockery -name Certification + // Certification is the interface for getting all the attributes for a given certification. // Schema info: https://github.com/opencontrol/schemas#certifications // diff --git a/pkg/lib/common/component.go b/pkg/lib/common/component.go index c00f20dd..0a88a625 100644 --- a/pkg/lib/common/component.go +++ b/pkg/lib/common/component.go @@ -2,6 +2,10 @@ package common import "github.com/blang/semver" +//go:generate mockery -name Component +//go:generate mockery -name Satisfies +//go:generate mockery -name Section + // Component is the basic building block for all systems. // Schema info: https://github.com/opencontrol/schemas#component-yaml // diff --git a/pkg/lib/common/control.go b/pkg/lib/common/control.go index 70a4b947..d2e79ff0 100644 --- a/pkg/lib/common/control.go +++ b/pkg/lib/common/control.go @@ -1,5 +1,7 @@ package common +//go:generate mockery -name Control + // Control is the interface for getting all the attributes for a given control. // Schema info: https://github.com/opencontrol/schemas#standards-documentation // diff --git a/pkg/lib/common/mocks/Certification.go b/pkg/lib/common/mocks/Certification.go index d0469b24..133cb4d7 100644 --- a/pkg/lib/common/mocks/Certification.go +++ b/pkg/lib/common/mocks/Certification.go @@ -1,6 +1,6 @@ +// Code generated by mockery v1.0.0. DO NOT EDIT. package mocks -import common "github.com/opencontrol/compliance-masonry/pkg/lib/common" import mock "github.com/stretchr/testify/mock" // Certification is an autogenerated mock type for the Certification type @@ -53,5 +53,3 @@ func (_m *Certification) GetSortedStandards() []string { return r0 } - -var _ common.Certification = (*Certification)(nil) diff --git a/pkg/lib/common/mocks/Component.go b/pkg/lib/common/mocks/Component.go index cc6674ec..c4f9160e 100644 --- a/pkg/lib/common/mocks/Component.go +++ b/pkg/lib/common/mocks/Component.go @@ -1,3 +1,4 @@ +// Code generated by mockery v1.0.0. DO NOT EDIT. package mocks import common "github.com/opencontrol/compliance-masonry/pkg/lib/common" @@ -122,5 +123,3 @@ func (_m *Component) SetKey(_a0 string) { func (_m *Component) SetVersion(_a0 semver.Version) { _m.Called(_a0) } - -var _ common.Component = (*Component)(nil) diff --git a/pkg/lib/common/mocks/Control.go b/pkg/lib/common/mocks/Control.go index 00311e90..b4bd9bbb 100644 --- a/pkg/lib/common/mocks/Control.go +++ b/pkg/lib/common/mocks/Control.go @@ -1,6 +1,6 @@ +// Code generated by mockery v1.0.0. DO NOT EDIT. package mocks -import common "github.com/opencontrol/compliance-masonry/pkg/lib/common" import mock "github.com/stretchr/testify/mock" // Control is an autogenerated mock type for the Control type @@ -8,8 +8,8 @@ type Control struct { mock.Mock } -// GetFamily provides a mock function with given fields: -func (_m *Control) GetFamily() string { +// GetDescription provides a mock function with given fields: +func (_m *Control) GetDescription() string { ret := _m.Called() var r0 string @@ -22,8 +22,8 @@ func (_m *Control) GetFamily() string { return r0 } -// GetName provides a mock function with given fields: -func (_m *Control) GetName() string { +// GetFamily provides a mock function with given fields: +func (_m *Control) GetFamily() string { ret := _m.Called() var r0 string @@ -36,8 +36,8 @@ func (_m *Control) GetName() string { return r0 } -// GetDescription provides a mock function with given fields: -func (_m *Control) GetDescription() string { +// GetName provides a mock function with given fields: +func (_m *Control) GetName() string { ret := _m.Called() var r0 string @@ -49,5 +49,3 @@ func (_m *Control) GetDescription() string { return r0 } - -var _ common.Control = (*Control)(nil) diff --git a/pkg/lib/common/mocks/OpenControl.go b/pkg/lib/common/mocks/OpenControl.go index cccf8d84..c48b8fbf 100644 --- a/pkg/lib/common/mocks/OpenControl.go +++ b/pkg/lib/common/mocks/OpenControl.go @@ -1,3 +1,4 @@ +// Code generated by mockery v1.0.0. DO NOT EDIT. package mocks import common "github.com/opencontrol/compliance-masonry/pkg/lib/common" @@ -103,5 +104,3 @@ func (_m *OpenControl) GetStandardsDependencies() []common.RemoteSource { return r0 } - -var _ common.OpenControl = (*OpenControl)(nil) diff --git a/pkg/lib/common/mocks/RemoteSource.go b/pkg/lib/common/mocks/RemoteSource.go index 4facbe72..8736fba7 100644 --- a/pkg/lib/common/mocks/RemoteSource.go +++ b/pkg/lib/common/mocks/RemoteSource.go @@ -1,6 +1,6 @@ +// Code generated by mockery v1.0.0. DO NOT EDIT. package mocks -import common "github.com/opencontrol/compliance-masonry/pkg/lib/common" import mock "github.com/stretchr/testify/mock" // RemoteSource is an autogenerated mock type for the RemoteSource type @@ -22,8 +22,8 @@ func (_m *RemoteSource) GetConfigFile() string { return r0 } -// GetRevision provides a mock function with given fields: -func (_m *RemoteSource) GetRevision() string { +// GetContextDir provides a mock function with given fields: +func (_m *RemoteSource) GetContextDir() string { ret := _m.Called() var r0 string @@ -36,8 +36,8 @@ func (_m *RemoteSource) GetRevision() string { return r0 } -// GetURL provides a mock function with given fields: -func (_m *RemoteSource) GetURL() string { +// GetRevision provides a mock function with given fields: +func (_m *RemoteSource) GetRevision() string { ret := _m.Called() var r0 string @@ -50,8 +50,8 @@ func (_m *RemoteSource) GetURL() string { return r0 } -// GetContextDir provides a mock function with given fields: -func (_m *RemoteSource) GetContextDir() string { +// GetURL provides a mock function with given fields: +func (_m *RemoteSource) GetURL() string { ret := _m.Called() var r0 string @@ -63,5 +63,3 @@ func (_m *RemoteSource) GetContextDir() string { return r0 } - -var _ common.RemoteSource = (*RemoteSource)(nil) diff --git a/pkg/lib/common/mocks/Satisfies.go b/pkg/lib/common/mocks/Satisfies.go index cb5bfaf2..7b35fa01 100644 --- a/pkg/lib/common/mocks/Satisfies.go +++ b/pkg/lib/common/mocks/Satisfies.go @@ -1,3 +1,4 @@ +// Code generated by mockery v1.0.0. DO NOT EDIT. package mocks import common "github.com/opencontrol/compliance-masonry/pkg/lib/common" @@ -143,5 +144,3 @@ func (_m *Satisfies) GetStandardKey() string { return r0 } - -var _ common.Satisfies = (*Satisfies)(nil) diff --git a/pkg/lib/common/mocks/Section.go b/pkg/lib/common/mocks/Section.go index a6202051..cc3b37c9 100644 --- a/pkg/lib/common/mocks/Section.go +++ b/pkg/lib/common/mocks/Section.go @@ -1,6 +1,6 @@ +// Code generated by mockery v1.0.0. DO NOT EDIT. package mocks -import common "github.com/opencontrol/compliance-masonry/pkg/lib/common" import mock "github.com/stretchr/testify/mock" // Section is an autogenerated mock type for the Section type @@ -35,5 +35,3 @@ func (_m *Section) GetText() string { return r0 } - -var _ common.Section = (*Section)(nil) diff --git a/pkg/lib/common/opencontrol.go b/pkg/lib/common/opencontrol.go index 61fc0dae..c50ad738 100644 --- a/pkg/lib/common/opencontrol.go +++ b/pkg/lib/common/opencontrol.go @@ -1,5 +1,8 @@ package common +//go:generate mockery -name OpenControl +//go:generate mockery -name RemoteSource + // OpenControl is an interface that every OpenControl yaml version should implement. // Schema info: https://github.com/opencontrol/schemas#opencontrolyaml // diff --git a/pkg/lib/common/standard.go b/pkg/lib/common/standard.go index 17748509..2785578d 100644 --- a/pkg/lib/common/standard.go +++ b/pkg/lib/common/standard.go @@ -1,5 +1,7 @@ package common +//go:generate mockery -name Standard -testonly + // Standard is the container of all the information for a particular Standard. // Schema info: https://github.com/opencontrol/schemas#standards-documentation // diff --git a/pkg/lib/common/workspace.go b/pkg/lib/common/workspace.go index 8b60900b..71dab7ad 100644 --- a/pkg/lib/common/workspace.go +++ b/pkg/lib/common/workspace.go @@ -1,5 +1,7 @@ package common +//go:generate mockery -name Workspace -testonly + // Workspace represents all the information such as components, standards, and certification as well as // the result information such as the justifications. type Workspace interface { diff --git a/pkg/lib/opencontrol/opencontrol.go b/pkg/lib/opencontrol/opencontrol.go index c40d2bea..bace4578 100644 --- a/pkg/lib/opencontrol/opencontrol.go +++ b/pkg/lib/opencontrol/opencontrol.go @@ -4,6 +4,8 @@ import ( "github.com/opencontrol/compliance-masonry/pkg/lib/common" ) +//go:generate mockery -name SchemaParser -testonly + // Base is the common struct that all schemas must have. type Base struct { // SchemaVersion contains the schema version. diff --git a/tools/fs/fs.go b/tools/fs/fs.go index d450c1f6..770737eb 100644 --- a/tools/fs/fs.go +++ b/tools/fs/fs.go @@ -9,6 +9,8 @@ import ( metaleapfs "github.com/metaleap/go-util/fs" ) +//go:generate mockery -name Util + // Util is an interface for helper file system utilities. type Util interface { OpenAndReadFile(file string) ([]byte, error) diff --git a/tools/fs/mocks/Util.go b/tools/fs/mocks/Util.go index 270b5fba..b3bdb672 100644 --- a/tools/fs/mocks/Util.go +++ b/tools/fs/mocks/Util.go @@ -1,33 +1,39 @@ +// Code generated by mockery v1.0.0. DO NOT EDIT. package mocks -import "github.com/stretchr/testify/mock" +import mock "github.com/stretchr/testify/mock" // Util is an autogenerated mock type for the Util type type Util struct { mock.Mock } -// OpenAndReadFile provides a mock function with given fields: file -func (_m *Util) OpenAndReadFile(file string) ([]byte, error) { - ret := _m.Called(file) +// AppendOrCreate provides a mock function with given fields: filePath, text +func (_m *Util) AppendOrCreate(filePath string, text string) error { + ret := _m.Called(filePath, text) - var r0 []byte - if rf, ok := ret.Get(0).(func(string) []byte); ok { - r0 = rf(file) + var r0 error + if rf, ok := ret.Get(0).(func(string, string) error); ok { + r0 = rf(filePath, text) } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]byte) - } + r0 = ret.Error(0) } - var r1 error - if rf, ok := ret.Get(1).(func(string) error); ok { - r1 = rf(file) + return r0 +} + +// Copy provides a mock function with given fields: source, destination +func (_m *Util) Copy(source string, destination string) error { + ret := _m.Called(source, destination) + + var r0 error + if rf, ok := ret.Get(0).(func(string, string) error); ok { + r0 = rf(source, destination) } else { - r1 = ret.Error(1) + r0 = ret.Error(0) } - return r0, r1 + return r0 } // CopyAll provides a mock function with given fields: source, destination @@ -44,13 +50,13 @@ func (_m *Util) CopyAll(source string, destination string) error { return r0 } -// Copy provides a mock function with given fields: source, destination -func (_m *Util) Copy(source string, destination string) error { - ret := _m.Called(source, destination) +// Mkdirs provides a mock function with given fields: dir +func (_m *Util) Mkdirs(dir string) error { + ret := _m.Called(dir) var r0 error - if rf, ok := ret.Get(0).(func(string, string) error); ok { - r0 = rf(source, destination) + if rf, ok := ret.Get(0).(func(string) error); ok { + r0 = rf(dir) } else { r0 = ret.Error(0) } @@ -58,20 +64,22 @@ func (_m *Util) Copy(source string, destination string) error { return r0 } -// TempDir provides a mock function with given fields: dir, prefix -func (_m *Util) TempDir(dir string, prefix string) (string, error) { - ret := _m.Called(dir, prefix) +// OpenAndReadFile provides a mock function with given fields: file +func (_m *Util) OpenAndReadFile(file string) ([]byte, error) { + ret := _m.Called(file) - var r0 string - if rf, ok := ret.Get(0).(func(string, string) string); ok { - r0 = rf(dir, prefix) + var r0 []byte + if rf, ok := ret.Get(0).(func(string) []byte); ok { + r0 = rf(file) } else { - r0 = ret.Get(0).(string) + if ret.Get(0) != nil { + r0 = ret.Get(0).([]byte) + } } var r1 error - if rf, ok := ret.Get(1).(func(string, string) error); ok { - r1 = rf(dir, prefix) + if rf, ok := ret.Get(1).(func(string) error); ok { + r1 = rf(file) } else { r1 = ret.Error(1) } @@ -79,30 +87,23 @@ func (_m *Util) TempDir(dir string, prefix string) (string, error) { return r0, r1 } -// Mkdirs provides a mock function with given fields: dir -func (_m *Util) Mkdirs(dir string) error { - ret := _m.Called(dir) +// TempDir provides a mock function with given fields: dir, prefix +func (_m *Util) TempDir(dir string, prefix string) (string, error) { + ret := _m.Called(dir, prefix) - var r0 error - if rf, ok := ret.Get(0).(func(string) error); ok { - r0 = rf(dir) + var r0 string + if rf, ok := ret.Get(0).(func(string, string) string); ok { + r0 = rf(dir, prefix) } else { - r0 = ret.Error(0) + r0 = ret.Get(0).(string) } - return r0 -} - -// AppendOrCreate provides a mock function with given fields: filePath, text -func (_m *Util) AppendOrCreate(filePath string, text string) error { - ret := _m.Called(filePath, text) - - var r0 error - if rf, ok := ret.Get(0).(func(string, string) error); ok { - r0 = rf(filePath, text) + var r1 error + if rf, ok := ret.Get(1).(func(string, string) error); ok { + r1 = rf(dir, prefix) } else { - r0 = ret.Error(0) + r1 = ret.Error(1) } - return r0 + return r0, r1 } diff --git a/tools/vcs/manager.go b/tools/vcs/manager.go index f37c0dd7..e866d452 100644 --- a/tools/vcs/manager.go +++ b/tools/vcs/manager.go @@ -7,6 +7,8 @@ import ( "github.com/Masterminds/vcs" ) +//go:generate mockery -name RepoManager + // RepoManager is the interface for how to do jobs with VCS type RepoManager interface { Clone(url string, revision string, dir string) error diff --git a/tools/vcs/mocks/RepoManager.go b/tools/vcs/mocks/RepoManager.go index 4cdf018e..811bbe22 100644 --- a/tools/vcs/mocks/RepoManager.go +++ b/tools/vcs/mocks/RepoManager.go @@ -1,6 +1,7 @@ +// Code generated by mockery v1.0.0. DO NOT EDIT. package mocks -import "github.com/stretchr/testify/mock" +import mock "github.com/stretchr/testify/mock" // RepoManager is an autogenerated mock type for the RepoManager type type RepoManager struct {