fixtures

package
v1.235.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 9 Imported by: 1 module, 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 fixtures builds the artifact test fixtures described by the artifact validation plan ("File package" and "Invalid package") with Go code inside a caller-supplied temporary directory. It never shells out, so it behaves identically on every platform.

Index

Constants

View Source
const (
	// RootReadme is the content of the root README.md, which stays ordinary payload.
	RootReadme = "# Root readme\n"

	// PackageReadme is the content of the distribution README in the reserved directory.
	PackageReadme = "# Package readme\n"

	// PackageChangelog is the content of the distribution CHANGELOG in the reserved directory.
	PackageChangelog = "# Changelog\n\n- first\n"

	// HelperScript is the content of the executable helper.
	HelperScript = "#!/bin/sh\necho helper\n"

	// UnicodeName is the Unicode filename in the file package.
	UnicodeName = "unicode-é-日本.txt"

	// ReservedDir is the reserved distribution directory below the source root.
	ReservedDir = ".atmos/artifact"
)

Well-known fixture content.

Variables

This section is empty.

Functions

func FilePackagePaths

func FilePackagePaths(symlinks bool) []string

FilePackagePaths lists the inventory paths of the file package in sorted order, excluding the reserved distribution directory and, when symlinks are unavailable, the symlink.

func MkdirAll

func MkdirAll(t testing.TB, dir, rel string)

MkdirAll creates the slash-separated directory below dir with mode 0755.

func POSIXModes

func POSIXModes() bool

POSIXModes reports whether the platform honors Unix permission bits. Windows does not, so tests that assert executable bits or mode-only changes skip there.

func RequirePOSIXModes

func RequirePOSIXModes(t testing.TB)

RequirePOSIXModes skips the test on platforms that ignore Unix permission bits.

func SpecialFile

func SpecialFile(t testing.TB, dir, rel string) bool

SpecialFile creates a named pipe (a special file) at rel below dir and reports whether it could.

func Symlink(t testing.TB, dir, rel, target string) bool

Symlink creates a symlink at rel pointing at target and reports false (leaving nothing behind) when the platform or account cannot create symlinks.

func WriteFile

func WriteFile(t testing.TB, dir, rel string, content string, mode fs.FileMode)

WriteFile writes content at the slash-separated rel path below dir and sets mode explicitly so the result does not depend on the process umask.

Types

type FilePackage

type FilePackage struct {
	// Dir is the source directory.
	Dir string

	// Symlinks reports whether the confined symlink could be created.
	Symlinks bool
}

FilePackage describes the files written by WriteFilePackage.

func WriteFilePackage

func WriteFilePackage(t testing.TB, dir string) FilePackage

WriteFilePackage writes the valid "File package" fixture into dir: nested files, an executable helper, an empty file, an empty directory, a confined symlink, a Unicode filename, a root README (ordinary payload), and a distinct package README and CHANGELOG in the reserved directory.

Jump to

Keyboard shortcuts

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