testhelper

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var InvalidContent = map[string]string{
	"json": `{"bad": }`,
	"yaml": "a: b\nc: d:::::::::::::::\n",
	"toml": "key = 123__456\n",
	"csv":  "This string has a \\\" in it",
}
View Source
var ValidContent = map[string]string{
	"json":         `{"key": "value"}`,
	"yaml":         "key: value\n",
	"yml":          "key: value\n",
	"toml":         "key = \"value\"\n",
	"csv":          "a,b,c\n1,2,3\n",
	"ini":          "[section]\nkey=value\n",
	"env":          "KEY=VALUE\n",
	"hcl":          "key = \"value\"\n",
	"xml":          "<root><key>value</key></root>",
	"properties":   "key=value\n",
	"hocon":        "key = value\n",
	"editorconfig": "root = true\n",
	"plist": `<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"><dict><key>k</key><string>v</string></dict></plist>`,
	"sarif": `{
		"version": "2.1.0",
		"$schema": "https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/schemas/sarif-schema-2.1.0.json",
		"runs": [{"tool": {"driver": {"name": "test", "language": "en"}}, "results": [], "language": "en", "newlineSequences": ["\n"]}]
	}`,
}

Minimal valid content for each file type

Functions

func CreateFixtureDir

func CreateFixtureDir(t *testing.T, extensions ...string) string

CreateFixtureDir creates a temp directory with valid config files for the given extensions. Returns the path to the temp directory.

func CreateFixtureFile

func CreateFixtureFile(t *testing.T, ext string) string

CreateFixtureFile creates a single temp file with the given extension and valid content. Returns the path to the file.

func CreateSubdir

func CreateSubdir(t *testing.T, dir, name string) string

CreateSubdir creates a subdirectory under dir and returns its path.

func WriteFile

func WriteFile(t *testing.T, dir, name, content string) string

WriteFile writes a file with the given name and content in dir. Returns the full path.

Types

This section is empty.

Jump to

Keyboard shortcuts

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