file

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package file assists in loading test files from the file system. Errors will call t.Error(err). Passing in `OptionNotRequired` will cause the function to fail if no file is found.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

type File struct {
	Path string
	Dir  string
	Base string

	// Extension will NOT include the preceding "."
	Extension string
	Root      string
	Data      string
}

func Glob

func Glob(t *testing.T, pattern string, options ...Option) []File

Glob takes in a glob pattern and will return the path, base file name, and read in contents. Will fail the test if the path pattern is bad. If OptionNotRequired is passed in, we will not fail if no files were found.

func Read

func Read(t *testing.T, path string, options ...Option) File

Read takes in a file path and returns a single File object. It will fail the test if the file is not found, unless OptionNotRequired is passed in.

type Option

type Option int
const (
	OptionUndefined Option = iota
	OptionNotRequired
)

Jump to

Keyboard shortcuts

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