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 gate verdict, 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());

Structs§

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.
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.
Repository
The repository side of a run, over whichever store holds its state.
VcsState
Everything the repository side of a run knows about itself.

Constants§

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.
STATE_VERSION
The version of the state document this build writes and reads.

Traits§

Checked
A state that can say whether it is one a provider may act on.
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.