open-nomad/plugins/device/mock.go

30 lines
853 B
Go
Raw Normal View History

2018-08-13 17:29:29 +00:00
package device
import (
"context"
"github.com/hashicorp/nomad/plugins/base"
)
// MockDevicePlugin is used for testing.
// Each function can be set as a closure to make assertions about how data
// is passed through the base plugin layer.
type MockDevicePlugin struct {
*base.MockPlugin
FingerprintF func(context.Context) (<-chan *FingerprintResponse, error)
ReserveF func([]string) (*ContainerReservation, error)
2018-08-27 23:11:07 +00:00
StatsF func(context.Context) (<-chan *StatsResponse, error)
2018-08-13 17:29:29 +00:00
}
func (p *MockDevicePlugin) Fingerprint(ctx context.Context) (<-chan *FingerprintResponse, error) {
return p.FingerprintF(ctx)
}
2018-08-27 23:11:07 +00:00
2018-08-13 17:29:29 +00:00
func (p *MockDevicePlugin) Reserve(devices []string) (*ContainerReservation, error) {
return p.ReserveF(devices)
}
2018-08-27 23:11:07 +00:00
func (p *MockDevicePlugin) Stats(ctx context.Context) (<-chan *StatsResponse, error) {
return p.StatsF(ctx)
}