tests

package
v0.0.0-...-6673b58 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2025 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanUpOldItems

func CleanUpOldItems(baseItemNames []string, getActualItems func() ([]string, error), deleteItem func(string))

Clean items with timestamp older than 24 hours. Used to delete old repositories, builds, release bundles and Docker images. baseItemNames - The items to delete without timestamp, i.e. [cli-rt1, cli-rt2, ...] getActualItems - Function that returns all actual items in the remote server, i.e. [cli-rt1-1592990748, cli-rt2-1592990748, ...] deleteItem - Function that deletes the item by name

func CompareTree

func CompareTree(expected, actual *xrayUtils.GraphNode) bool

CompareTree returns true iff the two trees contain the same nodes (regardless of their order)

func CreateTempDirWithCallbackAndAssert

func CreateTempDirWithCallbackAndAssert(t *testing.T) (string, func())

func CreateTestWorkspace

func CreateTestWorkspace(t *testing.T, sourceDir string) (string, func())

func GetAndAssertNode

func GetAndAssertNode(t *testing.T, modules []*xrayUtils.GraphNode, moduleId string) *xrayUtils.GraphNode

func GetModule

func GetModule(modules []*xrayUtils.GraphNode, moduleId string) *xrayUtils.GraphNode

GetModule gets a specific module from the provided modules list

func PrepareDotGitDir

func PrepareDotGitDir(t *testing.T, sourceDirPath, targetDirPath string) (string, string)

Prepare the .git environment for the test. Takes an existing folder and making it .git dir. sourceDirPath - Relative path to the source dir to change to .git targetDirPath - Relative path to the target created .git dir, usually 'testdata' under the parent dir.

func RedirectLogOutputToBuffer

func RedirectLogOutputToBuffer() (outputBuffer, stderrBuffer *bytes.Buffer, previousLog log.Log)

Set new logger with output redirection to a buffer. Caller is responsible to set the old log back.

func RedirectStdOutToPipe

func RedirectStdOutToPipe() (reader *os.File, writer *os.File, previousStdout *os.File)

Redirect stdout to new temp, os.pipe Caller is responsible to close the pipe and to set the old stdout back.

func RemovePath

func RemovePath(testPath string, t *testing.T)

Removing the provided path from the filesystem

func RenamePath

func RenamePath(oldPath, newPath string, t *testing.T)

Renaming from old path to new path.

func RunCmdWithOutput

func RunCmdWithOutput(t *testing.T, executeCmd func() error) string

Run a command, redirect the stdout and return the output

func RunCmdWithOutputs

func RunCmdWithOutputs(t *testing.T, executeCmd func() error) (output string, err error)

func SetJfrogHome

func SetJfrogHome() (cleanUp func(), err error)

Set HomeDir to desired location. Caller is responsible to set the old home location back.

func ValidateListsIdentical

func ValidateListsIdentical(expected, actual []string) error

Types

type JfrogCli

type JfrogCli struct {
	// contains filtered or unexported fields
}

func NewJfrogCli

func NewJfrogCli(mainFunc func() error, prefix, credentials string) *JfrogCli

func (*JfrogCli) Exec

func (cli *JfrogCli) Exec(args ...string) error

func (*JfrogCli) LegacyBuildToolExec

func (cli *JfrogCli) LegacyBuildToolExec(args ...string) error

func (*JfrogCli) RunCliCmdWithOutput

func (cli *JfrogCli) RunCliCmdWithOutput(t *testing.T, args ...string) string

Run `jfrog` command, redirect the stdout and return the output

func (*JfrogCli) RunCliCmdWithOutputs

func (cli *JfrogCli) RunCliCmdWithOutputs(t *testing.T, args ...string) (string, error)

func (*JfrogCli) SetPrefix

func (cli *JfrogCli) SetPrefix(prefix string) *JfrogCli

func (*JfrogCli) WithoutCredentials

func (cli *JfrogCli) WithoutCredentials() *JfrogCli

Jump to

Keyboard shortcuts

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