testtree

package
v0.29.2 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package testtree snapshots a directory tree in memory and restores it elsewhere. A test fixture that is expensive to build (a git repository takes a dozen processes) is built once and copied per test.

It is test support: production code never imports it (a test in internal/repodocs enforces that), and it imports neither internal/kb nor the testing package, so the tests of internal/kb can use it too.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	// Path is relative to the captured root, slash-separated.
	Path string
	// Mode carries the permission bits only.
	Mode fs.FileMode
	// Dir is true for a directory; Data is then nil.
	Dir  bool
	Data []byte
}

Entry is one directory or regular file of a Tree.

type Tree

type Tree []Entry

Tree is a directory tree, parents before their children.

func Capture

func Capture(dir string) (Tree, error)

Capture reads every directory and regular file under dir. Anything else (symlink, socket, device) is an error naming its path: a snapshot that silently dropped it would restore a different tree.

func (Tree) Restore

func (tr Tree) Restore(dir string) error

Restore creates dir and writes the tree into it, preserving the permission bits.

Jump to

Keyboard shortcuts

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