mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2025-06-26 18:18:24 +00:00
77
internal/modify/modify_mock.go
Normal file
77
internal/modify/modify_mock.go
Normal file
@@ -0,0 +1,77 @@
|
||||
// Code generated by moq; DO NOT EDIT.
|
||||
// github.com/matryer/moq
|
||||
|
||||
package modify
|
||||
|
||||
import (
|
||||
"github.com/NVIDIA/nvidia-container-toolkit/pkg/oci"
|
||||
"sync"
|
||||
)
|
||||
|
||||
// Ensure, that ModifierMock does implement Modifier.
|
||||
// If this is not the case, regenerate this file with moq.
|
||||
var _ Modifier = &ModifierMock{}
|
||||
|
||||
// ModifierMock is a mock implementation of Modifier.
|
||||
//
|
||||
// func TestSomethingThatUsesModifier(t *testing.T) {
|
||||
//
|
||||
// // make and configure a mocked Modifier
|
||||
// mockedModifier := &ModifierMock{
|
||||
// ModifyFunc: func(spec oci.Spec) error {
|
||||
// panic("mock out the Modify method")
|
||||
// },
|
||||
// }
|
||||
//
|
||||
// // use mockedModifier in code that requires Modifier
|
||||
// // and then make assertions.
|
||||
//
|
||||
// }
|
||||
type ModifierMock struct {
|
||||
// ModifyFunc mocks the Modify method.
|
||||
ModifyFunc func(spec oci.Spec) error
|
||||
|
||||
// calls tracks calls to the methods.
|
||||
calls struct {
|
||||
// Modify holds details about calls to the Modify method.
|
||||
Modify []struct {
|
||||
// Spec is the spec argument value.
|
||||
Spec oci.Spec
|
||||
}
|
||||
}
|
||||
lockModify sync.RWMutex
|
||||
}
|
||||
|
||||
// Modify calls ModifyFunc.
|
||||
func (mock *ModifierMock) Modify(spec oci.Spec) error {
|
||||
callInfo := struct {
|
||||
Spec oci.Spec
|
||||
}{
|
||||
Spec: spec,
|
||||
}
|
||||
mock.lockModify.Lock()
|
||||
mock.calls.Modify = append(mock.calls.Modify, callInfo)
|
||||
mock.lockModify.Unlock()
|
||||
if mock.ModifyFunc == nil {
|
||||
var (
|
||||
errOut error
|
||||
)
|
||||
return errOut
|
||||
}
|
||||
return mock.ModifyFunc(spec)
|
||||
}
|
||||
|
||||
// ModifyCalls gets all the calls that were made to Modify.
|
||||
// Check the length with:
|
||||
// len(mockedModifier.ModifyCalls())
|
||||
func (mock *ModifierMock) ModifyCalls() []struct {
|
||||
Spec oci.Spec
|
||||
} {
|
||||
var calls []struct {
|
||||
Spec oci.Spec
|
||||
}
|
||||
mock.lockModify.RLock()
|
||||
calls = mock.calls.Modify
|
||||
mock.lockModify.RUnlock()
|
||||
return calls
|
||||
}
|
||||
Reference in New Issue
Block a user