util

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2023 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertAllObfuscatorsTested added in v0.2.0

func AssertAllObfuscatorsTested(t *testing.T, obfuscators []*obfuscate.Obfuscator)

func AssertObfuscation added in v0.2.0

func AssertObfuscation(t *testing.T, obfuscators []*obfuscate.Obfuscator,
	kind obfuscate.Kind, name, input, expected string)

AssertObfuscation is a helper function for tests where we want to validate if obfuscation.Obfuscator works correctly.

func AssertObfuscationExample added in v0.2.0

func AssertObfuscationExample(t *testing.T, obfuscators []*obfuscate.Obfuscator, kind obfuscate.Kind, name string)

AssertObfuscationExample uses AssertObfuscation to assert but loads the example automatically from testdata.

Parameter `name` must correspond to the relative file name under testdata, or in case of a command, spaces are replaced by a minus sign, and txt is used for the file extension.

func CommandExists added in v0.5.0

func CommandExists(cmd string) bool

CommandExists returns true if command exists.

func GetHostnameWithoutDomain added in v0.9.0

func GetHostnameWithoutDomain() string

GetHostnameWithoutDomain returns hostname without domain.

func IsPrivilegedUser added in v0.2.0

func IsPrivilegedUser() bool

IsPrivilegedUser returns true when the current user is root.

func LoadTestdata added in v0.2.0

func LoadTestdata(t *testing.T, name string) string

LoadTestdata loads a file from the testdata directory and returns its contents as string.

Intended to load text file for comparison in assertions.

func StringInSlice added in v0.2.0

func StringInSlice(a string, list []string) bool

StringInSlice matches if a string is contained in a slice.

Types

type ExtraLogHook

type ExtraLogHook struct {
	Formatter logrus.Formatter
	Writer    io.Writer
	Level     logrus.Level
}

func (ExtraLogHook) Fire

func (h ExtraLogHook) Fire(entry *logrus.Entry) error

func (ExtraLogHook) Levels

func (h ExtraLogHook) Levels() []logrus.Level

Jump to

Keyboard shortcuts

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