Regenerate mocks for formatting

Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
Evan Lezar 2023-04-25 11:26:55 +02:00
parent bbb94be213
commit 2b5eeb8d24
6 changed files with 123 additions and 154 deletions

View File

@ -13,25 +13,25 @@ var _ Discover = &DiscoverMock{}
// DiscoverMock is a mock implementation of Discover. // DiscoverMock is a mock implementation of Discover.
// //
// func TestSomethingThatUsesDiscover(t *testing.T) { // func TestSomethingThatUsesDiscover(t *testing.T) {
// //
// // make and configure a mocked Discover // // make and configure a mocked Discover
// mockedDiscover := &DiscoverMock{ // mockedDiscover := &DiscoverMock{
// DevicesFunc: func() ([]Device, error) { // DevicesFunc: func() ([]Device, error) {
// panic("mock out the Devices method") // panic("mock out the Devices method")
// }, // },
// HooksFunc: func() ([]Hook, error) { // HooksFunc: func() ([]Hook, error) {
// panic("mock out the Hooks method") // panic("mock out the Hooks method")
// }, // },
// MountsFunc: func() ([]Mount, error) { // MountsFunc: func() ([]Mount, error) {
// panic("mock out the Mounts method") // panic("mock out the Mounts method")
// }, // },
// } // }
// //
// // use mockedDiscover in code that requires Discover // // use mockedDiscover in code that requires Discover
// // and then make assertions. // // and then make assertions.
// //
// } // }
type DiscoverMock struct { type DiscoverMock struct {
// DevicesFunc mocks the Devices method. // DevicesFunc mocks the Devices method.
DevicesFunc func() ([]Device, error) DevicesFunc func() ([]Device, error)
@ -78,7 +78,8 @@ func (mock *DiscoverMock) Devices() ([]Device, error) {
// DevicesCalls gets all the calls that were made to Devices. // DevicesCalls gets all the calls that were made to Devices.
// Check the length with: // Check the length with:
// len(mockedDiscover.DevicesCalls()) //
// len(mockedDiscover.DevicesCalls())
func (mock *DiscoverMock) DevicesCalls() []struct { func (mock *DiscoverMock) DevicesCalls() []struct {
} { } {
var calls []struct { var calls []struct {
@ -108,7 +109,8 @@ func (mock *DiscoverMock) Hooks() ([]Hook, error) {
// HooksCalls gets all the calls that were made to Hooks. // HooksCalls gets all the calls that were made to Hooks.
// Check the length with: // Check the length with:
// len(mockedDiscover.HooksCalls()) //
// len(mockedDiscover.HooksCalls())
func (mock *DiscoverMock) HooksCalls() []struct { func (mock *DiscoverMock) HooksCalls() []struct {
} { } {
var calls []struct { var calls []struct {
@ -138,7 +140,8 @@ func (mock *DiscoverMock) Mounts() ([]Mount, error) {
// MountsCalls gets all the calls that were made to Mounts. // MountsCalls gets all the calls that were made to Mounts.
// Check the length with: // Check the length with:
// len(mockedDiscover.MountsCalls()) //
// len(mockedDiscover.MountsCalls())
func (mock *DiscoverMock) MountsCalls() []struct { func (mock *DiscoverMock) MountsCalls() []struct {
} { } {
var calls []struct { var calls []struct {

View File

@ -13,29 +13,23 @@ var _ Locator = &LocatorMock{}
// LocatorMock is a mock implementation of Locator. // LocatorMock is a mock implementation of Locator.
// //
// func TestSomethingThatUsesLocator(t *testing.T) { // func TestSomethingThatUsesLocator(t *testing.T) {
// //
// // make and configure a mocked Locator // // make and configure a mocked Locator
// mockedLocator := &LocatorMock{ // mockedLocator := &LocatorMock{
// LocateFunc: func(s string) ([]string, error) { // LocateFunc: func(s string) ([]string, error) {
// panic("mock out the Locate method") // panic("mock out the Locate method")
// }, // },
// RelativeFunc: func(s string) (string, error) { // }
// panic("mock out the Relative method")
// },
// }
// //
// // use mockedLocator in code that requires Locator // // use mockedLocator in code that requires Locator
// // and then make assertions. // // and then make assertions.
// //
// } // }
type LocatorMock struct { type LocatorMock struct {
// LocateFunc mocks the Locate method. // LocateFunc mocks the Locate method.
LocateFunc func(s string) ([]string, error) LocateFunc func(s string) ([]string, error)
// RelativeFunc mocks the Relative method.
RelativeFunc func(s string) (string, error)
// calls tracks calls to the methods. // calls tracks calls to the methods.
calls struct { calls struct {
// Locate holds details about calls to the Locate method. // Locate holds details about calls to the Locate method.
@ -43,14 +37,8 @@ type LocatorMock struct {
// S is the s argument value. // S is the s argument value.
S string S string
} }
// Relative holds details about calls to the Relative method.
Relative []struct {
// S is the s argument value.
S string
}
} }
lockLocate sync.RWMutex lockLocate sync.RWMutex
lockRelative sync.RWMutex
} }
// Locate calls LocateFunc. // Locate calls LocateFunc.
@ -75,7 +63,8 @@ func (mock *LocatorMock) Locate(s string) ([]string, error) {
// LocateCalls gets all the calls that were made to Locate. // LocateCalls gets all the calls that were made to Locate.
// Check the length with: // Check the length with:
// len(mockedLocator.LocateCalls()) //
// len(mockedLocator.LocateCalls())
func (mock *LocatorMock) LocateCalls() []struct { func (mock *LocatorMock) LocateCalls() []struct {
S string S string
} { } {
@ -87,38 +76,3 @@ func (mock *LocatorMock) LocateCalls() []struct {
mock.lockLocate.RUnlock() mock.lockLocate.RUnlock()
return calls return calls
} }
// Relative calls RelativeFunc.
func (mock *LocatorMock) Relative(s string) (string, error) {
callInfo := struct {
S string
}{
S: s,
}
mock.lockRelative.Lock()
mock.calls.Relative = append(mock.calls.Relative, callInfo)
mock.lockRelative.Unlock()
if mock.RelativeFunc == nil {
var (
sOut string
errOut error
)
return sOut, errOut
}
return mock.RelativeFunc(s)
}
// RelativeCalls gets all the calls that were made to Relative.
// Check the length with:
// len(mockedLocator.RelativeCalls())
func (mock *LocatorMock) RelativeCalls() []struct {
S string
} {
var calls []struct {
S string
}
mock.lockRelative.RLock()
calls = mock.calls.Relative
mock.lockRelative.RUnlock()
return calls
}

View File

@ -13,19 +13,19 @@ var _ Runtime = &RuntimeMock{}
// RuntimeMock is a mock implementation of Runtime. // RuntimeMock is a mock implementation of Runtime.
// //
// func TestSomethingThatUsesRuntime(t *testing.T) { // func TestSomethingThatUsesRuntime(t *testing.T) {
// //
// // make and configure a mocked Runtime // // make and configure a mocked Runtime
// mockedRuntime := &RuntimeMock{ // mockedRuntime := &RuntimeMock{
// ExecFunc: func(strings []string) error { // ExecFunc: func(strings []string) error {
// panic("mock out the Exec method") // panic("mock out the Exec method")
// }, // },
// } // }
// //
// // use mockedRuntime in code that requires Runtime // // use mockedRuntime in code that requires Runtime
// // and then make assertions. // // and then make assertions.
// //
// } // }
type RuntimeMock struct { type RuntimeMock struct {
// ExecFunc mocks the Exec method. // ExecFunc mocks the Exec method.
ExecFunc func(strings []string) error ExecFunc func(strings []string) error
@ -62,7 +62,8 @@ func (mock *RuntimeMock) Exec(strings []string) error {
// ExecCalls gets all the calls that were made to Exec. // ExecCalls gets all the calls that were made to Exec.
// Check the length with: // Check the length with:
// len(mockedRuntime.ExecCalls()) //
// len(mockedRuntime.ExecCalls())
func (mock *RuntimeMock) ExecCalls() []struct { func (mock *RuntimeMock) ExecCalls() []struct {
Strings []string Strings []string
} { } {

View File

@ -14,28 +14,28 @@ var _ Spec = &SpecMock{}
// SpecMock is a mock implementation of Spec. // SpecMock is a mock implementation of Spec.
// //
// func TestSomethingThatUsesSpec(t *testing.T) { // func TestSomethingThatUsesSpec(t *testing.T) {
// //
// // make and configure a mocked Spec // // make and configure a mocked Spec
// mockedSpec := &SpecMock{ // mockedSpec := &SpecMock{
// FlushFunc: func() error { // FlushFunc: func() error {
// panic("mock out the Flush method") // panic("mock out the Flush method")
// }, // },
// LoadFunc: func() (*specs.Spec, error) { // LoadFunc: func() (*specs.Spec, error) {
// panic("mock out the Load method") // panic("mock out the Load method")
// }, // },
// LookupEnvFunc: func(s string) (string, bool) { // LookupEnvFunc: func(s string) (string, bool) {
// panic("mock out the LookupEnv method") // panic("mock out the LookupEnv method")
// }, // },
// ModifyFunc: func(specModifier SpecModifier) error { // ModifyFunc: func(specModifier SpecModifier) error {
// panic("mock out the Modify method") // panic("mock out the Modify method")
// }, // },
// } // }
// //
// // use mockedSpec in code that requires Spec // // use mockedSpec in code that requires Spec
// // and then make assertions. // // and then make assertions.
// //
// } // }
type SpecMock struct { type SpecMock struct {
// FlushFunc mocks the Flush method. // FlushFunc mocks the Flush method.
FlushFunc func() error FlushFunc func() error
@ -92,7 +92,8 @@ func (mock *SpecMock) Flush() error {
// FlushCalls gets all the calls that were made to Flush. // FlushCalls gets all the calls that were made to Flush.
// Check the length with: // Check the length with:
// len(mockedSpec.FlushCalls()) //
// len(mockedSpec.FlushCalls())
func (mock *SpecMock) FlushCalls() []struct { func (mock *SpecMock) FlushCalls() []struct {
} { } {
var calls []struct { var calls []struct {
@ -122,7 +123,8 @@ func (mock *SpecMock) Load() (*specs.Spec, error) {
// LoadCalls gets all the calls that were made to Load. // LoadCalls gets all the calls that were made to Load.
// Check the length with: // Check the length with:
// len(mockedSpec.LoadCalls()) //
// len(mockedSpec.LoadCalls())
func (mock *SpecMock) LoadCalls() []struct { func (mock *SpecMock) LoadCalls() []struct {
} { } {
var calls []struct { var calls []struct {
@ -155,7 +157,8 @@ func (mock *SpecMock) LookupEnv(s string) (string, bool) {
// LookupEnvCalls gets all the calls that were made to LookupEnv. // LookupEnvCalls gets all the calls that were made to LookupEnv.
// Check the length with: // Check the length with:
// len(mockedSpec.LookupEnvCalls()) //
// len(mockedSpec.LookupEnvCalls())
func (mock *SpecMock) LookupEnvCalls() []struct { func (mock *SpecMock) LookupEnvCalls() []struct {
S string S string
} { } {
@ -189,7 +192,8 @@ func (mock *SpecMock) Modify(specModifier SpecModifier) error {
// ModifyCalls gets all the calls that were made to Modify. // ModifyCalls gets all the calls that were made to Modify.
// Check the length with: // Check the length with:
// len(mockedSpec.ModifyCalls()) //
// len(mockedSpec.ModifyCalls())
func (mock *SpecMock) ModifyCalls() []struct { func (mock *SpecMock) ModifyCalls() []struct {
SpecModifier SpecModifier SpecModifier SpecModifier
} { } {

View File

@ -13,22 +13,22 @@ var _ Constraint = &ConstraintMock{}
// ConstraintMock is a mock implementation of Constraint. // ConstraintMock is a mock implementation of Constraint.
// //
// func TestSomethingThatUsesConstraint(t *testing.T) { // func TestSomethingThatUsesConstraint(t *testing.T) {
// //
// // make and configure a mocked Constraint // // make and configure a mocked Constraint
// mockedConstraint := &ConstraintMock{ // mockedConstraint := &ConstraintMock{
// AssertFunc: func() error { // AssertFunc: func() error {
// panic("mock out the Assert method") // panic("mock out the Assert method")
// }, // },
// StringFunc: func() string { // StringFunc: func() string {
// panic("mock out the String method") // panic("mock out the String method")
// }, // },
// } // }
// //
// // use mockedConstraint in code that requires Constraint // // use mockedConstraint in code that requires Constraint
// // and then make assertions. // // and then make assertions.
// //
// } // }
type ConstraintMock struct { type ConstraintMock struct {
// AssertFunc mocks the Assert method. // AssertFunc mocks the Assert method.
AssertFunc func() error AssertFunc func() error
@ -67,7 +67,8 @@ func (mock *ConstraintMock) Assert() error {
// AssertCalls gets all the calls that were made to Assert. // AssertCalls gets all the calls that were made to Assert.
// Check the length with: // Check the length with:
// len(mockedConstraint.AssertCalls()) //
// len(mockedConstraint.AssertCalls())
func (mock *ConstraintMock) AssertCalls() []struct { func (mock *ConstraintMock) AssertCalls() []struct {
} { } {
var calls []struct { var calls []struct {
@ -96,7 +97,8 @@ func (mock *ConstraintMock) String() string {
// StringCalls gets all the calls that were made to String. // StringCalls gets all the calls that were made to String.
// Check the length with: // Check the length with:
// len(mockedConstraint.StringCalls()) //
// len(mockedConstraint.StringCalls())
func (mock *ConstraintMock) StringCalls() []struct { func (mock *ConstraintMock) StringCalls() []struct {
} { } {
var calls []struct { var calls []struct {

View File

@ -13,31 +13,31 @@ var _ Property = &PropertyMock{}
// PropertyMock is a mock implementation of Property. // PropertyMock is a mock implementation of Property.
// //
// func TestSomethingThatUsesProperty(t *testing.T) { // func TestSomethingThatUsesProperty(t *testing.T) {
// //
// // make and configure a mocked Property // // make and configure a mocked Property
// mockedProperty := &PropertyMock{ // mockedProperty := &PropertyMock{
// CompareToFunc: func(s string) (int, error) { // CompareToFunc: func(s string) (int, error) {
// panic("mock out the CompareTo method") // panic("mock out the CompareTo method")
// }, // },
// NameFunc: func() string { // NameFunc: func() string {
// panic("mock out the Name method") // panic("mock out the Name method")
// }, // },
// StringFunc: func() string { // StringFunc: func() string {
// panic("mock out the String method") // panic("mock out the String method")
// }, // },
// ValidateFunc: func(s string) error { // ValidateFunc: func(s string) error {
// panic("mock out the Validate method") // panic("mock out the Validate method")
// }, // },
// ValueFunc: func() (string, error) { // ValueFunc: func() (string, error) {
// panic("mock out the Value method") // panic("mock out the Value method")
// }, // },
// } // }
// //
// // use mockedProperty in code that requires Property // // use mockedProperty in code that requires Property
// // and then make assertions. // // and then make assertions.
// //
// } // }
type PropertyMock struct { type PropertyMock struct {
// CompareToFunc mocks the CompareTo method. // CompareToFunc mocks the CompareTo method.
CompareToFunc func(s string) (int, error) CompareToFunc func(s string) (int, error)
@ -105,7 +105,8 @@ func (mock *PropertyMock) CompareTo(s string) (int, error) {
// CompareToCalls gets all the calls that were made to CompareTo. // CompareToCalls gets all the calls that were made to CompareTo.
// Check the length with: // Check the length with:
// len(mockedProperty.CompareToCalls()) //
// len(mockedProperty.CompareToCalls())
func (mock *PropertyMock) CompareToCalls() []struct { func (mock *PropertyMock) CompareToCalls() []struct {
S string S string
} { } {
@ -136,7 +137,8 @@ func (mock *PropertyMock) Name() string {
// NameCalls gets all the calls that were made to Name. // NameCalls gets all the calls that were made to Name.
// Check the length with: // Check the length with:
// len(mockedProperty.NameCalls()) //
// len(mockedProperty.NameCalls())
func (mock *PropertyMock) NameCalls() []struct { func (mock *PropertyMock) NameCalls() []struct {
} { } {
var calls []struct { var calls []struct {
@ -165,7 +167,8 @@ func (mock *PropertyMock) String() string {
// StringCalls gets all the calls that were made to String. // StringCalls gets all the calls that were made to String.
// Check the length with: // Check the length with:
// len(mockedProperty.StringCalls()) //
// len(mockedProperty.StringCalls())
func (mock *PropertyMock) StringCalls() []struct { func (mock *PropertyMock) StringCalls() []struct {
} { } {
var calls []struct { var calls []struct {
@ -197,7 +200,8 @@ func (mock *PropertyMock) Validate(s string) error {
// ValidateCalls gets all the calls that were made to Validate. // ValidateCalls gets all the calls that were made to Validate.
// Check the length with: // Check the length with:
// len(mockedProperty.ValidateCalls()) //
// len(mockedProperty.ValidateCalls())
func (mock *PropertyMock) ValidateCalls() []struct { func (mock *PropertyMock) ValidateCalls() []struct {
S string S string
} { } {
@ -229,7 +233,8 @@ func (mock *PropertyMock) Value() (string, error) {
// ValueCalls gets all the calls that were made to Value. // ValueCalls gets all the calls that were made to Value.
// Check the length with: // Check the length with:
// len(mockedProperty.ValueCalls()) //
// len(mockedProperty.ValueCalls())
func (mock *PropertyMock) ValueCalls() []struct { func (mock *PropertyMock) ValueCalls() []struct {
} { } {
var calls []struct { var calls []struct {