Documentation
¶
Overview ¶
Package cloudtest runs the steps of packs in tests, as a run does: the cloud service packs against local cloud emulators, the web pack against a site the test serves.
Index ¶
- Constants
- func AgainHosted(t *testing.T)
- func Emulator(t *testing.T, image, port, healthPath string, env map[string]string) string
- func EmulatorWithDocker(t *testing.T, image, port, healthPath string, env map[string]string) string
- func EmulatorWithSidecar(t *testing.T, image, port, healthPath string, env map[string]string, ...) string
- func Server(t *testing.T, image, port string, cmd []string, env map[string]string) string
- func ServerPorts(t *testing.T, image string, ports []string, cmd []string, ...) map[string]string
- func ValueProblems(t *testing.T, reg *match.Registry, text string) []string
- type Attachment
- type Harness
- func (h *Harness) End(status string) error
- func (h *Harness) Fails(text, want string, arg ...any) error
- func (h *Harness) File(name, content string)
- func (h *Harness) HostAsked() []core.HostApproval
- func (h *Harness) In(sc *core.Scenario) *Harness
- func (h *Harness) NewScenario() *core.Scenario
- func (h *Harness) NewScenarioWithin(limit time.Duration) *core.Scenario
- func (h *Harness) OK(text string, arg ...any)
- func (h *Harness) Plan(steps ...PlannedStep) *core.Plan
- func (h *Harness) Start(plan *core.Plan)
- func (h *Harness) Step(text string, arg ...any) (err error)
- func (h *Harness) ValueFails(text, want string)
- type PlannedStep
- type Sink
Constants ¶
const HostedEnv = "AXX_TEST_HOSTED"
HostedEnv, when set, gives every harness an axx host: the packs with a side in one (core.HostServer) do there what a run in a sandbox has the host do (web-core: start the browser), in this process, so the packs' tests run that way too.
Variables ¶
This section is empty.
Functions ¶
func AgainHosted ¶ added in v0.7.1
AgainHosted runs the package's tests again with HostedEnv set, in a process of their own: every step of a pack with a side in the host then crosses to the test's host and back. A package calls it from one test, in a file its integration build leaves out (a device's tests run hosted in CI's own parts). It does nothing in that second run, nor with -short.
func Emulator ¶
Emulator starts a container and returns its host address for port ("localhost:49153"). It skips the test when Docker is unavailable.
func EmulatorWithDocker ¶
EmulatorWithDocker is Emulator for emulators that run parts of a service in containers of their own (a message broker, say): the Docker socket is mounted.
func EmulatorWithSidecar ¶ added in v0.2.1
func EmulatorWithSidecar(t *testing.T, image, port, healthPath string, env map[string]string, sidecarImage, sidecarName, sidecarPort string) string
EmulatorWithSidecar is Emulator for an emulator that hands part of its work to a server of its own (floci-gcp its BigQuery SQL, to floci-duck): the two run on a network of their own, where the sidecar is named sidecarName and the emulator "emulator", so env can point each at the other (http://bigquery-sql:3000, http://emulator:4588).
func Server ¶ added in v0.1.5
Server starts a server's container, with the command it runs when cmd is not empty, and returns its host address for port once the port listens. It skips the test when Docker is unavailable.
Types ¶
type Attachment ¶ added in v0.1.1
Attachment is something a step attached.
type Harness ¶
type Harness struct {
Suite *core.Suite
// Dir is the project directory: relative files resolve against it.
Dir string
SC *core.Scenario
// Sink records what the scenarios log and attach.
Sink *Sink
// HostAnswer answers what a pack's side in the test's host asks its
// person to approve; nil approves.
HostAnswer func(core.HostApproval) error
// contains filtered or unexported fields
}
Harness runs step text against a set of packs, one scenario at a time.
func NewWithServices ¶ added in v0.2.0
NewWithServices is New with the services axx.yaml declares, as names and folders relative to the harness's project directory.
func (*Harness) End ¶ added in v0.1.1
End ends the scenario as the runner does: it records the outcome ("passed", "failed"...) and runs the packs' cleanup.
func (*Harness) HostAsked ¶ added in v0.7.1
func (h *Harness) HostAsked() []core.HostApproval
HostAsked are what the packs' sides in the test's host asked its person to approve, in order.
func (*Harness) In ¶ added in v0.1.1
In returns a harness that runs steps in another scenario of the same run, for scenarios running side by side. Use Step (not OK or Fails) from other goroutines. It takes only what does not change as h runs steps, so it can be called while h runs one.
func (*Harness) NewScenario ¶
NewScenario starts the next scenario, at line 1 of features/test.feature; its steps are on the lines after it.
func (*Harness) NewScenarioWithin ¶ added in v0.1.5
NewScenarioWithin starts the next scenario, which may take up to limit: for one on a machine known to be slow, like a simulator on a hosted runner.
func (*Harness) Plan ¶
func (h *Harness) Plan(steps ...PlannedStep) *core.Plan
Plan is a planned scenario of step texts with their tables, matched the way the engine plans a run.
func (*Harness) Start ¶
Start prepares and initializes the packs for a planned run, as the engine does before the scenarios start.
func (*Harness) ValueFails ¶ added in v0.3.0
ValueFails checks that a value in a step's own text that the rule cannot read (ADR 0014) fails the step with the message want and its code, as it runs, and that axx validate reports just that.
type PlannedStep ¶
PlannedStep is a step of a planned scenario.
type Sink ¶ added in v0.1.1
type Sink struct {
Logs []string
Attachments []Attachment
Announced []string
// contains filtered or unexported fields
}
Sink records scenario logs and attachments, and what packs announce to an IDE.