mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2024-11-25 21:39:10 +00:00
b8acd7657a
Signed-off-by: Evan Lezar <elezar@nvidia.com>
77 lines
1.6 KiB
Go
77 lines
1.6 KiB
Go
// Code generated by moq; DO NOT EDIT.
|
|
// github.com/matryer/moq
|
|
|
|
package oci
|
|
|
|
import (
|
|
"sync"
|
|
)
|
|
|
|
// Ensure, that RuntimeMock does implement Runtime.
|
|
// If this is not the case, regenerate this file with moq.
|
|
var _ Runtime = &RuntimeMock{}
|
|
|
|
// RuntimeMock is a mock implementation of Runtime.
|
|
//
|
|
// func TestSomethingThatUsesRuntime(t *testing.T) {
|
|
//
|
|
// // make and configure a mocked Runtime
|
|
// mockedRuntime := &RuntimeMock{
|
|
// ExecFunc: func(strings []string) error {
|
|
// panic("mock out the Exec method")
|
|
// },
|
|
// }
|
|
//
|
|
// // use mockedRuntime in code that requires Runtime
|
|
// // and then make assertions.
|
|
//
|
|
// }
|
|
type RuntimeMock struct {
|
|
// ExecFunc mocks the Exec method.
|
|
ExecFunc func(strings []string) error
|
|
|
|
// calls tracks calls to the methods.
|
|
calls struct {
|
|
// Exec holds details about calls to the Exec method.
|
|
Exec []struct {
|
|
// Strings is the strings argument value.
|
|
Strings []string
|
|
}
|
|
}
|
|
lockExec sync.RWMutex
|
|
}
|
|
|
|
// Exec calls ExecFunc.
|
|
func (mock *RuntimeMock) Exec(strings []string) error {
|
|
callInfo := struct {
|
|
Strings []string
|
|
}{
|
|
Strings: strings,
|
|
}
|
|
mock.lockExec.Lock()
|
|
mock.calls.Exec = append(mock.calls.Exec, callInfo)
|
|
mock.lockExec.Unlock()
|
|
if mock.ExecFunc == nil {
|
|
var (
|
|
errOut error
|
|
)
|
|
return errOut
|
|
}
|
|
return mock.ExecFunc(strings)
|
|
}
|
|
|
|
// ExecCalls gets all the calls that were made to Exec.
|
|
// Check the length with:
|
|
// len(mockedRuntime.ExecCalls())
|
|
func (mock *RuntimeMock) ExecCalls() []struct {
|
|
Strings []string
|
|
} {
|
|
var calls []struct {
|
|
Strings []string
|
|
}
|
|
mock.lockExec.RLock()
|
|
calls = mock.calls.Exec
|
|
mock.lockExec.RUnlock()
|
|
return calls
|
|
}
|