gitfixture

package
v0.2.14 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 16, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package gitfixture is the Git repository and the keys a test serves through test/e2e/gitserver: the git-sources acceptance phase serves them on kind, and the runner harness (test/runnerharness) from a container. One definition, so the documents the harness captures answer the repository the phase reads.

Index

Constants

View Source
const (
	// Repository is the repository's path on the server.
	Repository = "acme/app.git"
	// SchemaPath and MigrationPath are what a source selects.
	SchemaPath    = "db/schema.sql"
	MigrationPath = "db/migrations"
	// SubmodulePath and LFSPath are what only the refused sources select: a
	// submodule that links to a commit this repository does not hold, as a
	// real one would not, and a Git LFS pointer file as Git LFS writes one.
	SubmodulePath   = "db/vendor"
	SubmoduleCommit = "0123456789abcdef0123456789abcdef01234567"
	LFSPath         = "db/lfs.sql"
	LFSPointer      = "version https://git-lfs.github.com/spec/v1\n" +
		"oid sha256:4d7a214614ab2935c943f9e0ff69d22eadbb8f32b1258daaa5e2ca24d17e2393\nsize 12345\n"
)

Variables

View Source
var MigrationFiles = map[string]string{
	"0000000001_create_parts.up.sql":   "CREATE TABLE e2e_git_parts (\n    id INTEGER PRIMARY KEY,\n    name TEXT NOT NULL\n);\n",
	"0000000001_create_parts.down.sql": "DROP TABLE e2e_git_parts;\n",
}

MigrationFiles is the migration directory, which no commit changes.

View Source
var SchemaRevisions = []string{
	"CREATE TABLE e2e_git_items (\n  id bigint NOT NULL PRIMARY KEY,\n  name text NOT NULL\n);\n",
	"CREATE TABLE e2e_git_items (\n  id bigint NOT NULL PRIMARY KEY,\n  name text NOT NULL,\n  sku text\n);\n",
	"CREATE TABLE e2e_git_items (\n  id bigint NOT NULL PRIMARY KEY,\n  name text NOT NULL,\n  sku text,\n  code text\n);\n",
}

SchemaRevisions are the desired schema, in order: a table, then a column on it, then, after the history is rewritten, a second column.

Functions

func MigrationContent

func MigrationContent() (string, error)

MigrationContent is the content digest of the migration directory.

func RepositorySpec

func RepositorySpec(main int) gitrepo.Spec

RepositorySpec is the repository the server holds, with main at the commit at index main. Commit 0 creates the table, commit 1 changes only a file no resource selects, and commit 2 adds the column; the tag v1 names commit 0, whose migration directory the migration reads. Every commit also holds a submodule and an LFS pointer, which only the refused sources select.

func RewrittenSpec

func RewrittenSpec() gitrepo.Spec

RewrittenSpec is the repository after a force-push: commit 2 is replaced by one that adds a second column, main names the replacement, and the replaced commit is no longer on the server.

func SchemaContent

func SchemaContent(revision int) (string, error)

SchemaContent is the content digest of a schema revision as the operator binds it: one file, by its own name.

func SpecDocument

func SpecDocument(spec gitrepo.Spec) (string, error)

SpecDocument is a spec in the form the server reads.

Types

type Keys

type Keys struct {
	CAPEM, CertificatePEM, KeyPEM []byte
	Token                         string
	HostKeyPEM, ClientKeyPEM      []byte
	AuthorizedKey, KnownHosts     []byte
	// OtherKnownHosts pins a host key the server does not hold.
	OtherKnownHosts []byte
}

Keys is everything a test generates for its Git server: a CA and a certificate for the server's names, the token, the server's SSH host key and the one client key it authorizes, and the known-hosts line that pins the host key. None of it outlives the test.

func NewKeys

func NewKeys(host string, names ...string) (Keys, error)

NewKeys generates keys for a server at host, with a certificate for names.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL