lookup

package
v1.11.0-rc.3 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPath

func GetPath(root string) string

GetPath returns a colon-separated path value that can be used to set the PATH environment variable

func GetPaths

func GetPaths(root string) []string

GetPaths returns a list of paths for a specified root. These are constructed from the PATH environment variable, a default path list, and the supplied root.

Types

type Locator

type Locator interface {
	Locate(string) ([]string, error)
}

Locator defines the interface for locating files on a system.

func NewCharDeviceLocator

func NewCharDeviceLocator(logger *logrus.Logger, root string) Locator

NewCharDeviceLocator creates a Locator that can be used to find char devices at the specified root. A logger is also specified.

func NewDirectoryLocator

func NewDirectoryLocator(logger *log.Logger, root string) Locator

NewDirectoryLocator creates a Locator that can be used to find directories at the specified root. A logger is also specified.

func NewExecutableLocator

func NewExecutableLocator(logger *log.Logger, root string) Locator

NewExecutableLocator creates a locator to fine executable files in the path. A logger can also be specified.

func NewFileLocator

func NewFileLocator(logger *log.Logger, root string) Locator

NewFileLocator creates a Locator that can be used to find files at the specified root. A logger can also be specified.

func NewSymlinkChainLocator

func NewSymlinkChainLocator(logger *logrus.Logger, root string) Locator

NewSymlinkChainLocator creats a locator that can be used for locating files through symlinks. A logger can also be specified.

func NewSymlinkLocator

func NewSymlinkLocator(logger *logrus.Logger, root string) Locator

NewSymlinkLocator creats a locator that can be used for locating files through symlinks. A logger can also be specified.

type LocatorMock

type LocatorMock struct {
	// LocateFunc mocks the Locate method.
	LocateFunc func(s string) ([]string, error)

	// RelativeFunc mocks the Relative method.
	RelativeFunc func(s string) (string, error)
	// contains filtered or unexported fields
}

LocatorMock is a mock implementation of Locator.

func TestSomethingThatUsesLocator(t *testing.T) {

	// make and configure a mocked Locator
	mockedLocator := &LocatorMock{
		LocateFunc: func(s string) ([]string, error) {
			panic("mock out the Locate method")
		},
		RelativeFunc: func(s string) (string, error) {
			panic("mock out the Relative method")
		},
	}

	// use mockedLocator in code that requires Locator
	// and then make assertions.

}

func (*LocatorMock) Locate

func (mock *LocatorMock) Locate(s string) ([]string, error)

Locate calls LocateFunc.

func (*LocatorMock) LocateCalls

func (mock *LocatorMock) LocateCalls() []struct {
	S string
}

LocateCalls gets all the calls that were made to Locate. Check the length with:

len(mockedLocator.LocateCalls())

func (*LocatorMock) Relative added in v1.11.0

func (mock *LocatorMock) Relative(s string) (string, error)

Relative calls RelativeFunc.

func (*LocatorMock) RelativeCalls added in v1.11.0

func (mock *LocatorMock) RelativeCalls() []struct {
	S string
}

RelativeCalls gets all the calls that were made to Relative. Check the length with:

len(mockedLocator.RelativeCalls())

Jump to

Keyboard shortcuts

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