arktest

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package arktest holds the conformance suites every ark implementation runs.

The suites are ordinary Go tests driven by a factory, so an out-of-tree backend proves the same contract as the in-tree ones:

func TestConformance(t *testing.T) {
	arktest.RunBackendTests(t, func(t *testing.T) ark.Backend {
		return mybackend.New()
	})
}

The package depends on the standard library and ark itself, nothing else.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunBackendTests

func RunBackendTests(t *testing.T, factory func(t *testing.T) ark.Backend)

RunBackendTests checks a backend against the contract documented on ark.Backend. factory is called once per sub-test and returns a backend with no objects in it; the suite closes what it creates.

Every sub-test is independent, so a failure names the clause it broke.

func RunSourceSinkTests

func RunSourceSinkTests(
	t *testing.T,
	typ ark.SourceType,
	newSource func(t *testing.T, location string) ark.Source,
	newSink func(t *testing.T) (ark.Sink, string),
)

RunSourceSinkTests checks one Source and Sink pair against the contract in package ark: what the Sink receives, the Source yields again.

typ is the source type the pair produces and accepts; the suite opens the Sink under it. newSink returns a Sink over a fresh, empty medium and the location that medium can be reopened from; newSource opens a Source over such a location. The location is whatever names one medium for the implementation, a directory for arkfs and a volume name for arkdocker.

func TestSourceSinkConformance(t *testing.T) {
	arktest.RunSourceSinkTests(t, ark.SourceTypeFile,
		func(t *testing.T, loc string) ark.Source { ... },
		func(t *testing.T) (ark.Sink, string) { ... },
	)
}

Types

type Entry

type Entry struct {
	Path     string
	Type     ark.FileType
	Mode     os.FileMode
	Content  string
	LinkDest string
	Xattrs   map[string][]byte
}

Entry is one filesystem entry the source and sink suite writes and reads back. It is the suite's own shape, close to ark.FileInfo but carrying the content instead of a reader.

Jump to

Keyboard shortcuts

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