e2e

package
v0.13.2 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2019 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAPIServerTestParams

func NewAPIServerTestParams() runtime.Params

NewAPIServerTestParams creates a new set of runtime.Params with enough default values filled in to start the server. Options can/should be customized for the test case.

Types

type TestRuntime

type TestRuntime struct {
	Params  runtime.Params
	Runtime *runtime.Runtime
	Ctx     context.Context
	Cancel  context.CancelFunc
	Client  *http.Client
	// contains filtered or unexported fields
}

TestRuntime holds metadata and provides helper methods to interact with the runtime being tested.

func NewTestRuntime

func NewTestRuntime(params runtime.Params) (*TestRuntime, error)

NewTestRuntime returns a new TestRuntime which

func (*TestRuntime) GetDataWithInput

func (t *TestRuntime) GetDataWithInput(path string, input interface{}) ([]byte, error)

GetDataWithInput will use the v1 data API and POST with the given input. The returned value is the full response body.

func (*TestRuntime) RunAPIServerBenchmarks

func (t *TestRuntime) RunAPIServerBenchmarks(m *testing.M) int

RunAPIServerBenchmarks will start the OPA runtime and do `m.Run()` similar to how RunAPIServerTests works. This will suppress logging output on stdout to prevent the tests from being overly verbose. If log output is desired set the `test.v` flag.

func (*TestRuntime) RunAPIServerTests

func (t *TestRuntime) RunAPIServerTests(m *testing.M) int

RunAPIServerTests will start the OPA runtime serving with a given configuration. This is essentially a wrapper for `m.Run()` that handles starting and stopping the local API server. The return value is what should be used as the code in `os.Exit` in the `TestMain` function.

func (*TestRuntime) URL

func (t *TestRuntime) URL() string

URL will return the URL that the server is listening on. If the server hasn't started listening this will return an empty string. It is not expected for the URL to change throughout the lifetime of the TestRuntime. Runtimes configured with >1 address will only get the first URL.

func (*TestRuntime) UploadData

func (t *TestRuntime) UploadData(data io.Reader) error

UploadData will upload the given data to the runtime via the v1 data API

func (*TestRuntime) UploadPolicy

func (t *TestRuntime) UploadPolicy(name string, policy io.Reader) error

UploadPolicy will upload the given policy to the runtime via the v1 policy API

Jump to

Keyboard shortcuts

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