open-nomad/plugins/drivers/testing_test.go
2018-10-16 16:56:57 -07:00

26 lines
670 B
Go

package drivers
import (
"testing"
cstructs "github.com/hashicorp/nomad/client/structs"
"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{
StartTaskF: func(task *TaskConfig) (*TaskHandle, *cstructs.DriverNetwork, error) {
return handle, nil, nil
},
}
harness := NewDriverHarness(t, d)
defer harness.Kill()
actual, _, err := harness.StartTask(&TaskConfig{})
require.NoError(t, err)
require.Equal(t, handle.Config.Name, actual.Config.Name)
}