plugin/driver: fix tests and add new dep to vendor

This commit is contained in:
Nick Ethier
2019-05-08 10:30:10 -04:00
parent 4a8a96fa1a
commit bc71cafcee
6 changed files with 481 additions and 0 deletions

View File

@@ -175,6 +175,15 @@ type Capabilities struct {
MustInitiateNetwork bool
}
func (c *Capabilities) HasNetIsolationMode(m NetIsolationMode) bool {
for _, mode := range c.NetIsolationModes {
if mode == m {
return true
}
}
return false
}
type NetIsolationMode string
var (

View File

@@ -195,6 +195,19 @@ type MockDriver struct {
SignalTaskF func(string, string) error
ExecTaskF func(string, []string, time.Duration) (*drivers.ExecTaskResult, error)
ExecTaskStreamingF func(context.Context, string, *drivers.ExecOptions) (*drivers.ExitResult, error)
MockNetworkManager
}
type MockNetworkManager struct {
CreateNetworkF func(string) (*drivers.NetworkIsolationSpec, error)
DestroyNetworkF func(string, *drivers.NetworkIsolationSpec) error
}
func (m *MockNetworkManager) CreateNetwork(id string) (*drivers.NetworkIsolationSpec, error) {
return m.CreateNetworkF(id)
}
func (m *MockNetworkManager) DestroyNetwork(id string, spec *drivers.NetworkIsolationSpec) error {
return m.DestroyNetworkF(id, spec)
}
func (d *MockDriver) TaskConfigSchema() (*hclspec.Spec, error) { return d.TaskConfigSchemaF() }