nvidia-container-toolkit/internal/system/nvmodules/cmd_mock.go

84 lines
1.7 KiB
Go
Raw Permalink Normal View History

// Code generated by moq; DO NOT EDIT.
// github.com/matryer/moq
package nvmodules
import (
"sync"
)
// Ensure, that cmderMock does implement cmder.
// If this is not the case, regenerate this file with moq.
var _ cmder = &cmderMock{}
// cmderMock is a mock implementation of cmder.
//
// func TestSomethingThatUsescmder(t *testing.T) {
//
// // make and configure a mocked cmder
// mockedcmder := &cmderMock{
// RunFunc: func(s string, strings ...string) error {
// panic("mock out the Run method")
// },
// }
//
// // use mockedcmder in code that requires cmder
// // and then make assertions.
//
// }
type cmderMock struct {
// RunFunc mocks the Run method.
RunFunc func(s string, strings ...string) error
// calls tracks calls to the methods.
calls struct {
// Run holds details about calls to the Run method.
Run []struct {
// S is the s argument value.
S string
// Strings is the strings argument value.
Strings []string
}
}
lockRun sync.RWMutex
}
// Run calls RunFunc.
func (mock *cmderMock) Run(s string, strings ...string) error {
callInfo := struct {
S string
Strings []string
}{
S: s,
Strings: strings,
}
mock.lockRun.Lock()
mock.calls.Run = append(mock.calls.Run, callInfo)
mock.lockRun.Unlock()
if mock.RunFunc == nil {
var (
errOut error
)
return errOut
}
return mock.RunFunc(s, strings...)
}
// RunCalls gets all the calls that were made to Run.
// Check the length with:
//
// len(mockedcmder.RunCalls())
func (mock *cmderMock) RunCalls() []struct {
S string
Strings []string
} {
var calls []struct {
S string
Strings []string
}
mock.lockRun.RLock()
calls = mock.calls.Run
mock.lockRun.RUnlock()
return calls
}