servicetest

package
v0.0.0-...-d500d3c Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2019 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package servicetest provides tests to ensure that implementations of platform/task/backend.Store and platform/task/backend.LogReader meet the requirements of platform.TaskService.

Consumers of this package must import query/builtin. This package does not import it directly, to avoid requiring it too early.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TestTaskService

func TestTaskService(t *testing.T, fn BackendComponentFactory)

TestTaskService should be called by consumers of the servicetest package. This will call fn once to create a single platform.TaskService used across all subtests in TestTaskService.

Types

type BackendComponentFactory

type BackendComponentFactory func(t *testing.T) (*System, context.CancelFunc)

BackendComponentFactory is supplied by consumers of the adaptertest package, to provide the values required to constitute a PlatformAdapter. The provided context.CancelFunc is called after the test, and it is the implementer's responsibility to clean up after that is called.

If creating the System fails, the implementer should call t.Fatal.

type System

type System struct {
	S   backend.Store
	LR  backend.LogReader
	LW  backend.LogWriter
	Sch backend.Scheduler

	// Set this context, to be used in tests, so that any spawned goroutines watching Ctx.Done()
	// will clean up after themselves.
	Ctx context.Context

	// Override for how to create a TaskService.
	// Most callers should leave this nil, in which case the tests will call task.PlatformAdapter.
	TaskServiceFunc func() platform.TaskService

	// Override for accessing credentials for an individual test.
	// Callers can leave this nil and the test will create its own random IDs for each test.
	// However, if the system needs to verify a token, organization, or user,
	// the caller should set this value and return valid IDs and a token.
	// It is safe if this returns the same values every time it is called.
	CredsFunc func() (orgID, userID platform.ID, token string, err error)
	// contains filtered or unexported fields
}

System, as in "system under test", encapsulates the required parts of a platform.TaskAdapter (the underlying Store, LogReader, and LogWriter) for low-level operations.

Jump to

Keyboard shortcuts

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