testutils

package
v0.0.0-...-141d866 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MockSCPPath              = "/usr/bin/scp"
	MockSSHPath              = "/usr/bin/ssh"
	MockSSHPassPath          = "/usr/bin/sshpass" // #nosec G101
	MockSSHPassword          = "hunter2"
	MockSSHPassphrase        = "correct horse battery staple"
	MockIdentityFileContents = "-----BEGIN OPENSSH PRIVATE KEY-----"
	WantFilePermissions      = os.FileMode(0o600)
)

The constants here are used by both the SCP & SSH Plugins for testing.

Variables

This section is empty.

Functions

func ArgCompare

func ArgCompare(wantArgs, gotArgs []string) bool

ArgCompare will allow us to compare some command line arguments to validate they match what we'd expect. We can't directly use a reflect.DeepEqual because of some randomized file names/suffixes.

func CreateMockFiles

func CreateMockFiles(t *testing.T, filename ...string) afero.Fs

CreateMockFiles will create an in memory file system along with any arbitrary named empty files for testing.

func FlattenArguments

func FlattenArguments(args ...interface{}) (flatArgs []string)

FlattenArguments is a helper to smash together strings and string slices into a flat string slice for testing purposes.

func ValidateMockFile

func ValidateMockFile(t *testing.T, fs afero.Fs, wantFilePath, wantFileContents string)

ValidateMockFile checks to ensure that particular files exist along with specific permissions and contents as a common action used in tests.

Types

This section is empty.

Jump to

Keyboard shortcuts

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