Skip to main content

Crate onevcs_testing

Crate onevcs_testing 

Source
Expand description

Test implementations of the two interfaces onevcs is built around.

onevcs declares Vcs and RemoteHost so that a second implementation can be supplied, and Providers is where one is. This crate is that second implementation: four providers, two flavours of each interface, so a consumer can drive a real onevcs through a real journey without a real GitHub — and without the scripted fake binary that substituting the whole CLI amounts to.

§Why a separate crate rather than a feature

Cargo features are additive across a dependency graph, so a feature that switched these on could be switched on by somebody else’s dependency and end up inside a release binary. A crate a consumer puts in dev-dependencies cannot.

§The two flavours

StateUse it when
MemoryVcs / MemoryHostthis processone invocation, no filesystem, fastest
FileVcs / FileHostone JSON documentseveral invocations that must see one another

Both flavours are one implementation over a different Store, so a behaviour cannot exist in one and not the other. Both are constructible empty and seeded from a VcsState or HostState, and both hand their state back.

§What they are honest about

They emit the events the real implementations emit, into the same $ONEVCS_HOME stream the real ones write, so onevcs events TOKEN and onevcs artifact cat ID read a provider’s run exactly as they read a real one. That is checked rather than asserted: publication_events_match_across_backends in the crate next door runs one publication twice — once on Git + GitHub, once on these — and holds the two event streams to each other.

What they are not is git and GitHub. Nothing here clones, commits, pushes, or moves a ref; a merge records an outcome and no origin advances. A journey about git drives the real Git. A publication is the sharpest case of that: its host side really happens — a change request is opened, adopted, and merged on the Hosting it was handed — and its repository side does not, so nothing here emits a fetch, a push, or a lock it did not take.

use onevcs::{Providers, cli::Cli, run_with};
use onevcs_testing::{MemoryHost, MemoryVcs};
use clap::Parser;

let vcs = MemoryVcs::new();
let host = MemoryHost::new();
let cli = Cli::parse_from(["onevcs", "recoverable"]);
let code = run_with(&cli, Providers { vcs: &vcs, hosting: &host });

assert_eq!(code, 0);
assert!(vcs.state().preserved.is_empty());

Modules§

boundary
The public boundary’s budget workload, over real Git and the production registry. The public boundary’s budget workload: one host the release-binary journeys time the publication term check and an export over.
recovery
Shared full-size fixtures over real Git and production persistence. Full-size real-Git recovery fixtures shared by the producer and its consumers.

Structs§

Described
One description a host was handed for a change request after it was opened.
FileStore
State held in one JSON document, so a second process — the next onevcs invocation — sees what the first one left.
Host
The remote-host side of a run, over whichever store holds its state.
HostCall
One host call a host answered, as its ledger records it.
HostComment
One comment a host holds on a change request.
HostState
Everything the remote-host side of a run knows about itself.
MemoryStore
State held in this process and nowhere else: no disk, and no visibility to a second process.
Replied
One reply a host posted.
Repository
The repository side of a run, over whichever store holds its state.
VcsState
Everything the repository side of a run knows about itself.

Enums§

ActivityAnswer
One answer a host gives about the work still running on a change request’s head — what HostState::head_activity scripts per call.
Dependants
What deleting a merged change request’s head does to the change requests based on it.
HeadAfter
What becomes of a merged change request’s head branch.
PersonMerge
How a person merges a change request on the host.

Constants§

DEFAULT_APPROVALS
The approvals a publication takes when nothing was seeded: the contract’s own default:, as DEFAULT_PUBLICATION is.
DEFAULT_AUTHENTICATED_USER
Who a host with nothing seeded says is calling.
DEFAULT_BASE
The base a session is cut from when the request names none.
DEFAULT_HOST
The host a change request’s URL names, matching the one implementation the crate next door speaks for.
DEFAULT_PUBLICATION
The policy a publication takes when nothing was seeded and nothing requested.
DEFAULT_SLUG
The repository a host answers for when it was not addressed at one — which is the case only when a journey holds it directly rather than through Hosting::for_repo.
OLDEST_READABLE_VERSION
The oldest document version this build reads.
STATE_VERSION
The version of the state document this build writes.

Traits§

Checked
A state that can say whether it is one a provider may act on, and what it becomes when it arrived at an older version.
Store
A provider’s state, however it is kept.

Type Aliases§

FileHost
A host provider that keeps its state in one JSON document, so several onevcs invocations see one another’s change requests.
FileVcs
A repository provider that keeps its state in one JSON document, so several onevcs invocations see one another’s effects.
MemoryHost
A host provider that keeps its state in this process.
MemoryVcs
A repository provider that keeps its state in this process: no disk, no visibility to a second process, and the fastest of the two.