github.com/zoomfoo/nomad@v0.8.5-0.20180907175415-f28fd3a1a056/plugins/device/mock.go (about) 1 package device 2 3 import ( 4 "context" 5 6 "github.com/hashicorp/nomad/plugins/base" 7 ) 8 9 // MockDevicePlugin is used for testing. 10 // Each function can be set as a closure to make assertions about how data 11 // is passed through the base plugin layer. 12 type MockDevicePlugin struct { 13 *base.MockPlugin 14 FingerprintF func(context.Context) (<-chan *FingerprintResponse, error) 15 ReserveF func([]string) (*ContainerReservation, error) 16 StatsF func(context.Context) (<-chan *StatsResponse, error) 17 } 18 19 func (p *MockDevicePlugin) Fingerprint(ctx context.Context) (<-chan *FingerprintResponse, error) { 20 return p.FingerprintF(ctx) 21 } 22 23 func (p *MockDevicePlugin) Reserve(devices []string) (*ContainerReservation, error) { 24 return p.ReserveF(devices) 25 } 26 27 func (p *MockDevicePlugin) Stats(ctx context.Context) (<-chan *StatsResponse, error) { 28 return p.StatsF(ctx) 29 }