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
| State | Use it when | |
|---|---|---|
MemoryVcs / MemoryHost | this process | one invocation, no filesystem, fastest |
FileVcs / FileHost | one JSON document | several 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§
- File
Store - State held in one JSON document, so a second process — the next
onevcsinvocation — sees what the first one left. - Host
- The remote-host side of a run, over whichever store holds its state.
- Host
State - Everything the remote-host side of a run knows about itself.
- Memory
Store - 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§
- File
Host - A host provider that keeps its state in one JSON document, so several
onevcsinvocations see one another’s change requests. - FileVcs
- A repository provider that keeps its state in one JSON document, so several
onevcsinvocations see one another’s effects. - Memory
Host - A host provider that keeps its state in this process.
- Memory
Vcs - A repository provider that keeps its state in this process: no disk, no visibility to a second process, and the fastest of the two.