Skip to main content

internal/conformance/runner.go

internal/conformance · 410 lines · 13 declarations · source

Declarations

type Driver

type Driver interface {
Run(ctx context.Context, instruction Instruction) (Report, error)
}

Driver is the adapter under test, however it is reached: in this process for the reference, over a subprocess for an adapter in another language.

source

type Deployment

type Deployment struct {
API string
Token string
}

Deployment is the live deployment the suite runs against, reached with a write-enabled credential for one project. Every case uses a data subject of its own, so cases isolate without the runner reaching into the database.

source

type Result

type Result struct {
Case string `json:"case"`
Rule string `json:"rule"`
Passed bool `json:"passed"`
Failures []string `json:"failures,omitempty"`
}

Result is one case's verdict with every failure named.

source

func Load

func Load(path string) (Suite, error)

Load reads a suite file.

source

func Run

func Run(ctx context.Context, deployment Deployment, driver Driver, suite Suite) ([]Result, error)

Run executes every case against the deployment through the driver and returns a verdict per case. It returns an error only when the suite could not run at all; a failing case is a result.

source

func runCase

func runCase(ctx context.Context, client *apiClient, p *proxy, driver Driver, c Case) (Result, error)

source

func judge

func judge(expect Expect, report Report, recorded []Recorded, stored int64) []string

judge is the whole of what the suite asserts, in one place, so a reader can see every rule beside the field that holds it.

source

type apiClient

type apiClient struct {
base string
token string
http *http.Client
}

apiClient is the runner's own view of the deployment, never through the proxy.

source

method apiClient.seed

func (c *apiClient) seed(ctx context.Context, subject string, seeds []Seed) error

seed asserts the case's facts under its subject, dated in the past so recall as of now finds them, through the authored-assertion operation: curated evidence that replays with no model.

source

method apiClient.stored

func (c *apiClient) stored(ctx context.Context) (int64, error)

stored reads how many observations the project holds, as the freshness watermark's stored offset plus one, or zero before the first; the difference across a turn is what the store rules are judged by, and it needs no database.

source

method apiClient.post

func (c *apiClient) post(ctx context.Context, path string, body any) (int, []byte, error)

source

method apiClient.get

func (c *apiClient) get(ctx context.Context, path string) (int, []byte, error)

source

method apiClient.do

func (c *apiClient) do(req *http.Request) (int, []byte, error)

do sends one of the runner's own requests. A 429 here is the deployment's admission gate refusing the runner's bookkeeping, not the adapter under test, and the contract tells every client what to do with it: retry with backoff. Bounded, so a deployment that refuses everything still ends the run with the refusal in hand rather than a hang.

source