2018-09-26 17:33:37 +00:00
|
|
|
package drivers
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2018-10-16 23:52:58 +00:00
|
|
|
cstructs "github.com/hashicorp/nomad/client/structs"
|
2018-09-26 17:33:37 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
var _ DriverPlugin = (*MockDriver)(nil)
|
|
|
|
|
|
|
|
// Very simple test to ensure the test harness works as expected
|
|
|
|
func TestDriverHarness(t *testing.T) {
|
|
|
|
handle := &TaskHandle{Config: &TaskConfig{Name: "mock"}}
|
|
|
|
d := &MockDriver{
|
2018-10-16 23:52:58 +00:00
|
|
|
StartTaskF: func(task *TaskConfig) (*TaskHandle, *cstructs.DriverNetwork, error) {
|
|
|
|
return handle, nil, nil
|
2018-09-26 17:33:37 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
harness := NewDriverHarness(t, d)
|
|
|
|
defer harness.Kill()
|
2018-10-16 23:52:58 +00:00
|
|
|
actual, _, err := harness.StartTask(&TaskConfig{})
|
2018-09-26 17:33:37 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, handle.Config.Name, actual.Config.Name)
|
|
|
|
}
|