Documentation
¶
Overview ¶
Package readertest is the shared test kit of the RepoReader adapters: Git fixtures built with the git binary, the conformance table every adapter must pass, and the comparison of one adapter with another.
Index ¶
- Variables
- func CommitObjects(t *testing.T, mk CommitObjectsMaker)
- func Compare(t *testing.T, want, got ports.RepoReader, repo domain.RepoName, dir string, ...)
- func Conformance(t *testing.T, mk Maker)
- func GitOut(t testing.TB, dir string, args ...string) string
- func MustID(t *testing.T, s string) domain.ObjectID
- func ObjectID(t testing.TB, s string) domain.ObjectID
- func RandomBytes(n int, seed uint64) []byte
- func RepoName(t testing.TB, s string) domain.RepoName
- func Rev(t *testing.T, s string) domain.Revision
- func TreePath(t *testing.T, s string) domain.TreePath
- type Budget
- type Case
- type CommitObjectsMaker
- type Fixture
- func (f *Fixture) Checkout(branch string)
- func (f *Fixture) CheckoutNew(branch string)
- func (f *Fixture) Chmod(p string, mode os.FileMode) *Fixture
- func (f *Fixture) Commit(msg string) string
- func (f *Fixture) Git(args ...string) string
- func (f *Fixture) Lines(p, prefix string, n int) *Fixture
- func (f *Fixture) Maintain()
- func (f *Fixture) Merge(branch string) string
- func (f *Fixture) Mv(from, to string) *Fixture
- func (f *Fixture) Path(p string) string
- func (f *Fixture) Remove(p string) *Fixture
- func (f *Fixture) Symlink(target, p string) *Fixture
- func (f *Fixture) Write(p, content string) *Fixture
- func (f *Fixture) WriteBytes(p string, content []byte) *Fixture
- func (f *Fixture) WriteObject(typ, content string) string
- type History
- type Maker
- type Queries
Constants ¶
This section is empty.
Variables ¶
var LargeBudget = Budget{Revs: 4, LogRevs: 2, Dirs: 6, Files: 8, LogPaths: 5, LastTrees: 3}
LargeBudget suits a repository of thousands of commits.
var SmallBudget = Budget{Revs: 24, LogRevs: 8, Dirs: 10, Files: 10, LogPaths: 6, LastTrees: 6}
SmallBudget suits the fixtures.
Functions ¶
func CommitObjects ¶ added in v0.26.0
func CommitObjects(t *testing.T, mk CommitObjectsMaker)
CommitObjects runs the CommitObjectReader contract against the readers mk builds: the raw bytes of unsigned and SSH-signed commits equal `git cat-file commit`; missing ids, trees and blobs are left out; a missing repository is domain.ErrNotFound; too many ids are domain.ErrInvalid.
func Compare ¶
Compare asks both readers the same questions about the repository and requires the same answers: the same values, and the same kind of error. want is the oracle (the CLI reader).
func Conformance ¶
Conformance runs the RepoReader contract against the readers mk builds: every adapter that serves repositories must pass it, whatever its route.
func RandomBytes ¶
RandomBytes returns n deterministic incompressible bytes.
Types ¶
type Budget ¶
type Budget struct {
Revs int // revisions (refs and commits) for trees and blobs
LogRevs int // revisions for history pages
Dirs int // directories per revision
Files int // files per revision
LogPaths int // paths for path-limited history
LastTrees int // trees listed with last commits
}
Budget bounds how many revisions and paths Compare asks about, so that it stays fast on a large repository.
type Case ¶
Case is a repository the readers are compared on.
func Cases ¶
func Cases() []Case
Cases are the fixtures of the comparison: everything the gitcli tests use, plus merges, tags, deep paths, a large blob, an unborn HEAD, repositories with and without commit-graph (Bloom filters v1 and v2), and one whose graph is stale because commits were pushed after the last maintenance.
type CommitObjectsMaker ¶ added in v0.26.0
type CommitObjectsMaker func(t *testing.T) (ports.CommitObjectReader, string)
CommitObjectsMaker builds a CommitObjectReader serving the repositories below data/repos, and returns it with the data directory.
type Fixture ¶
Fixture builds a repository with real git: a bare repository in the data directory, and a work tree beside it that the helpers edit and commit.
func NewFixture ¶
NewFixture creates an empty bare repository repos/<name>.git whose HEAD is refs/heads/main.
func (*Fixture) CheckoutNew ¶
CheckoutNew creates a branch from the current HEAD and switches to it.
func (*Fixture) Commit ¶
Commit stages everything and commits with the next timestamp; it returns the commit id.
func (*Fixture) Maintain ¶
func (f *Fixture) Maintain()
Maintain runs what ermite runs after a push: a split commit-graph with changed-path Bloom filters.
func (*Fixture) WriteBytes ¶
WriteBytes is Write for binary content.
func (*Fixture) WriteObject ¶
WriteObject stores a raw object of the given type (commit, tag...) built by hand, for what git itself refuses to write, and returns its id.
type History ¶
History is the repository of the read tests: three commits on main, a branch with a slash, a merge, lightweight and annotated tags.
type Maker ¶
type Maker func(t *testing.T) (ports.RepoReader, string)
Maker builds a RepoReader serving the repositories below data/repos, and returns it with the data directory. The reader is closed when the test ends.