tests

package
v0.1.1-rc3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 10, 2016 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TestExecutors = func(
	config gofig.Config,
	client types.Client, t *testing.T) {

	reply, err := client.API().Executors(nil)
	if err != nil {
		t.Fatal(err)
	}

	assertLSXLinux(t, reply["lsx-linux"])
	assertLSXDarwin(t, reply["lsx-darwin"])
}

TestExecutors tests the GET /executors route.

View Source
var TestExecutorsWithControllerClient = func(
	config gofig.Config,
	client types.Client, t *testing.T) {

	_, err := client.API().Executors(nil)
	assert.Error(t, err)
	assert.Equal(t, "unsupported op for client type", err.Error())
}

TestExecutorsWithControllerClient tests the GET /executors route using a controller client.

View Source
var TestGetExecutorDarwin = func(
	config gofig.Config,
	client types.Client, t *testing.T) {

	reply, err := client.API().ExecutorGet(nil, "lsx-darwin")
	if err != nil {
		t.Fatal(err)
	}
	defer reply.Close()
	buf, err := ioutil.ReadAll(reply)
	if err != nil {
		t.Fatal(err)
	}
	assert.EqualValues(t, lsxDarwinInfo.Size, len(buf))
}

TestGetExecutorDarwin tests the GET /executors/lsx-darwin route.

View Source
var TestGetExecutorLinux = func(
	config gofig.Config,
	client types.Client, t *testing.T) {

	reply, err := client.API().ExecutorGet(nil, "lsx-linux")
	if err != nil {
		t.Fatal(err)
	}
	defer reply.Close()
	buf, err := ioutil.ReadAll(reply)
	if err != nil {
		t.Fatal(err)
	}
	assert.EqualValues(t, lsxLinuxInfo.Size, len(buf))
}

TestGetExecutorLinux tests the GET /executors/lsx-linux route.

View Source
var TestHeadExecutorDarwin = func(
	config gofig.Config,
	client types.Client, t *testing.T) {

	reply, err := client.API().ExecutorHead(nil, "lsx-darwin")
	if err != nil {
		t.Fatal(err)
	}
	assertLSXDarwin(t, reply)
}

TestHeadExecutorDarwin tests the HEAD /executors/lsx-darwin route.

View Source
var TestHeadExecutorLinux = func(
	config gofig.Config,
	client types.Client, t *testing.T) {

	reply, err := client.API().ExecutorHead(nil, "lsx-linux")
	if err != nil {
		t.Fatal(err)
	}
	assertLSXLinux(t, reply)
}

TestHeadExecutorLinux tests the HEAD /executors/lsx-linux route.

View Source
var TestRoot = func(config gofig.Config, client types.Client, t *testing.T) {
	reply, err := client.API().Root(nil)
	if err != nil {
		t.Fatal(err)
	}
	assert.Equal(t, len(reply), 6)
}

TestRoot tests the GET / route.

Functions

func Debug

func Debug(
	t *testing.T,
	driverName string,
	config []byte,
	tests ...APITestFunc)

Debug is the same as Run except with additional logging.

func DebugGroup

func DebugGroup(
	t *testing.T,
	driverName string,
	config []byte,
	tests ...APITestFunc)

DebugGroup is the same as RunGroup except with additional logging.

func LogAsJSON

func LogAsJSON(i interface{}, t *testing.T)

LogAsJSON logs the object as JSON using the test logger.

func Run

func Run(
	t *testing.T,
	driverName string,
	config []byte,
	tests ...APITestFunc)

Run executes the provided tests in a new test harness. Each test is executed against a new server instance.

func RunGroup

func RunGroup(
	t *testing.T,
	driverName string,
	config []byte,
	tests ...APITestFunc)

RunGroup executes the provided tests in a new test harness. All tests are executed against the same server instance.

func RunGroupWithClientType added in v0.1.1

func RunGroupWithClientType(
	t *testing.T,
	clientType types.ClientType,
	driverName string,
	config []byte,
	tests ...APITestFunc)

RunGroupWithClientType executes the provided tests in a new test harness with the specified client type. All tests are executed against the same server instance.

func RunWithClientType added in v0.1.1

func RunWithClientType(
	t *testing.T,
	clientType types.ClientType,
	driverName string,
	config []byte,
	tests ...APITestFunc)

RunWithClientType executes the provided tests in a new test harness with the specified client type. Each test is executed against a new server instance.

Types

type APITestFunc

type APITestFunc func(config gofig.Config, client types.Client, t *testing.T)

APITestFunc is a function that wraps a block of test logic for testing the API. An APITestFunc is executed four times:

1 - tcp
2 - tcp+tls
3 - sock
4 - sock+tls

type InstanceIDTest

type InstanceIDTest struct {

	// Driver is the name of the driver/executor for which to get the instance
	// ID.
	Driver string

	// Expected is the expected instance ID value.
	Expected *types.InstanceID
}

InstanceIDTest is the test harness for testing the instance ID.

func (*InstanceIDTest) Test

func (tt *InstanceIDTest) Test(
	config gofig.Config,
	client types.Client,
	t *testing.T)

Test is the APITestFunc for the InstanceIDTest.

type InstanceTest

type InstanceTest struct {

	// Driver is the name of the driver/executor for which to inspect the
	// instance.
	Driver string

	// Expected is the expected instance.
	Expected *types.Instance
}

InstanceTest is the test harness for testing instance inspection.

func (*InstanceTest) Test

func (tt *InstanceTest) Test(
	config gofig.Config,
	client types.Client,
	t *testing.T)

Test is the APITestFunc for the InstanceTest.

type LocalDevicesTest

type LocalDevicesTest struct {

	// Driver is the name of the driver/executor for which to get the local
	// devices.
	Driver string

	// Expected is the expected local devices.
	Expected *types.LocalDevices
}

LocalDevicesTest is the test harness for testing getting the local devices.

func (*LocalDevicesTest) Test

func (tt *LocalDevicesTest) Test(
	config gofig.Config,
	client types.Client,
	t *testing.T)

Test is the APITestFunc for the LocalDevicesTest.

type NextDeviceTest

type NextDeviceTest struct {

	// Driver is the name of the driver/executor for which to get the next
	// device.
	Driver string

	// Expected is the expected next device.
	Expected string
}

NextDeviceTest is the test harness for testing getting the next device.

func (*NextDeviceTest) Test

func (tt *NextDeviceTest) Test(
	config gofig.Config,
	client types.Client,
	t *testing.T)

Test is the APITestFunc for the NextDeviceTest.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL