testutil

package
v0.0.0-...-20901c0 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CI

func CI() string

CI tries to detect if the test is being run on a CI server. If so, a string identifying the CI is returned. The current implementation reports as follows: - GitHub Actions: "github" - No CI: ""

func LogBuffer

func LogBuffer() *bytes.Buffer

LogBuffer redirects output from the builtin logger to a new buffer and returns this buffer.

func MakeDirAccessible

func MakeDirAccessible(dirPath string) error

MakeDirAccessible is a noop except when running on Windows. On Windows, it makes the directory on the provided path fully accessible to the user running the test by invoking 'icacls'. This is necessary to allow the test to delete the temporary directory after having made it inaccessible using MakeDirInaccessible.

func MakeDirInaccessible

func MakeDirInaccessible(dirPath string) error

MakeDirInaccessible makes the directory at the provided path non-readable to the user running the test. On Unix, this is done by zeroing the permission bits. On Windows, this method can only be used to control the "write" flag (https://golang.org/pkg/os/#Chmod), so we invoke 'icacls' to deny access. The function is only intended to be used on temporary directories that get deleted as part of cleaning up after the test. Use MakeDirAccessible to make the directory deletable.

func MakeFileInaccessible

func MakeFileInaccessible(f *os.File) error

MakeFileInaccessible makes the provided file non-readable to the user running the test. On Unix, this is done by zeroing the permission bits. On Windows, this method can only be used to control the "write" flag (https://golang.org/pkg/os/#Chmod), so we invoke 'icacls' to deny access. The function is only intended to be used on temporary files that get deleted as part of cleaning up after the test. On none of the tested platforms does it prevent deletion of the file that it has been made inaccessible.

Types

This section is empty.

Jump to

Keyboard shortcuts

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