Documentation
¶
Overview ¶
Package testfixture owns disk scenarios and their isolated repositories and caches.
Index ¶
- type Case
- type Fixture
- func (f *Fixture) Cache(tb testing.TB, inv *Invocation) string
- func (f *Fixture) CachePath(name string) string
- func (f *Fixture) Edit(tb testing.TB, step Step)
- func (f *Fixture) Load(endpoint *transport.Endpoint) (storer.Storer, error)
- func (f *Fixture) Read(tb testing.TB, path, cache string) string
- func (f *Fixture) Resolve(tb testing.TB, value, cache string) string
- func (f *Fixture) Restore(tb testing.TB)
- type Invocation
- type Response
- type Step
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Case ¶
type Case struct {
Name string `json:"name"`
Description string `json:"description"`
Setup []operation `json:"setup"`
Directory string `json:"directory,omitempty"`
Env map[string]string `json:"env"`
Cache replayCache `json:"cache"`
Steps []Step `json:"steps"`
}
Case requires an explicit cache policy and ordered edits or invocations.
type Fixture ¶
type Fixture struct {
Plan Case
Repo string
Inputs string
Home string
Responses []Response
// contains filtered or unexported fields
}
Fixture isolates materialized state from the immutable disk scenario.
func Materialize ¶
Materialize locates scenarios independently of the current working directory.
func (*Fixture) Cache ¶
func (f *Fixture) Cache(tb testing.TB, inv *Invocation) string
Cache resets only the cache selected by the invocation.
type Invocation ¶
type Invocation struct {
Argv []string `json:"argv"`
Transport []Response `json:"transport,omitempty"`
Env map[string]string `json:"env,omitempty"`
Cache cacheSelection `json:"cache"`
Expect expectation `json:"expect"`
}
Invocation requires complete output and exit-code expectations.
type Response ¶
type Response struct {
Host string `json:"host"`
Method string `json:"method"`
Path string `json:"path"`
Status int `json:"status,omitempty"`
Error string `json:"error,omitempty"`
Headers map[string]string `json:"headers,omitempty"`
Body string `json:"body,omitempty"`
}
Response limits fixture transport to a declared host, method, and path.
type Step ¶
type Step struct {
ID string `json:"id"`
Edit *operation `json:"edit,omitempty"`
Invoke *Invocation `json:"invoke,omitempty"`
}
Step permits exactly one edit or invocation.
Click to show internal directories.
Click to hide internal directories.