fixture

package
v0.0.0-...-a69e935 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2019 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package fixture provides testing fixtures for aurorabridge.

A fixture is a function which returns a type populated with randomized testing data. They are an answer to global test constants and copy-and-pasting arbitrarily populated structs around test files. Fixtures are useful for high-level tests which just need some valid data to plumb through mocks.

The philosophy of fixtures is that tests should only declare data relevant to the test. Tests should be easy to write, easier to read, and focus only on details that affect the passage or failure of the test. Anything else is a distraction.

When to use a fixture:

  • Your test doesn't care what the data is, it just needs something to mock against.
  • Your test needs a lot of unique data.

When to NOT use a fixture:

  • Your test depends on some carefully constructed data, e.g. events ordered in a special way or integers with an exact value. In these cases, construct the data directly in the test.

When to maybe use a fixture:

  • Your test doesn't care what *most* of the data is, but is very interested in a specific field. In this case, it can be appropriate to call a fixture but overwrite the desired field.

What fixtures should look like:

  • Prefers building on other fixtures instead of taking parameters. Note, in some situations parameters can still be useful as long as they are simple.
  • Random values still make sense semantically, e.g. instance count is between 1-10000 and service name looks like "service-ahgb73".

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuroraInstanceSet

func AuroraInstanceSet(n, max int) map[int32]struct{}

AuroraInstanceSet returns n random instances whose values are less than max with no duplicates. Panics if n > max.

func AuroraJobKey

func AuroraJobKey() *api.JobKey

AuroraJobKey returns a random JobKey.

func AuroraJobUpdateKey

func AuroraJobUpdateKey() *api.JobUpdateKey

AuroraJobUpdateKey returns a random JobUpdateKey.

func AuroraJobUpdateRequest

func AuroraJobUpdateRequest() *api.JobUpdateRequest

AuroraJobUpdateRequest returns a random JobUpdateRequest.

func AuroraMetadata

func AuroraMetadata() []*api.Metadata

AuroraMetadata returns a list of random Metadata.

func AuroraTaskConfig

func AuroraTaskConfig() *api.TaskConfig

AuroraTaskConfig returns a random TaskConfig.

func AuroraTaskQuery

func AuroraTaskQuery() *api.TaskQuery

AuroraTaskQuery returns a random TaskQuery containing a random job_key.

func DefaultPelotonJobLabels

func DefaultPelotonJobLabels(jobKey *api.JobKey) []*peloton.Label

DefaultPelotonJobLabels returns a list of default labels for peloton jobs

func PelotonEntityVersion

func PelotonEntityVersion(vs ...int) *peloton.EntityVersion

PelotonEntityVersion returns a random EntityVersion.

func PelotonJobID

func PelotonJobID() *peloton.JobID

PelotonJobID returns a random JobID.

func PelotonOpaqueData

func PelotonOpaqueData() *peloton.OpaqueData

PelotonOpaqueData returns opaque data with a random update id.

func PelotonResourcePoolID

func PelotonResourcePoolID() *peloton.ResourcePoolID

PelotonResourcePoolID returns a random ResourcePoolID.

func PelotonUpdateSpec

func PelotonUpdateSpec() *stateless.UpdateSpec

PelotonUpdateSpec returns a random UpdateSpec.

func PelotonWorkflowInfo

func PelotonWorkflowInfo(eventTimestamp string) *stateless.WorkflowInfo

PelotonWorkflowInfo returns a random WorkflowInfo.

Types

This section is empty.

Jump to

Keyboard shortcuts

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