testutil

package
v0.0.0-...-b5b5a37 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2026 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotExist string = lo.Ternary(runtime.GOOS == "windows",
	"The system cannot find the file specified.",
	"no such file or directory")

Functions

func AssertDefsecEqual

func AssertDefsecEqual(t *testing.T, expected, actual any)

func AssertRuleFound

func AssertRuleFound(t *testing.T, ruleID string, results scan.Results, message string, args ...any)

func AssertRuleNotFailed

func AssertRuleNotFailed(t *testing.T, ruleID string, results scan.Results, message string, args ...any)

func AssertRuleNotFound

func AssertRuleNotFound(t *testing.T, ruleID string, results scan.Results, message string, args ...any)

func CopyDir

func CopyDir(t *testing.T, src, dst string)

CopyDir copies the directory content from src to dst. It supports only simple cases for testing.

func CopyFile

func CopyFile(t *testing.T, src, dst string)

func CreateFS

func CreateFS(files map[string]string) fs.FS

func DecompressGzip

func DecompressGzip(t *testing.T, src, dst string)

func DecompressSparseGzip

func DecompressSparseGzip(t *testing.T, src, dst string)

DecompressSparseGzip decompresses a sparse gzip file for virtual machine image.

func ImageName

func ImageName(subpath, tag, digest string) string

func MustMkdirAll

func MustMkdirAll(t *testing.T, dir string)

func MustParseReference

func MustParseReference(t *testing.T, s string) name.Reference

MustParseReference parses a string into a Reference and fails the test if there's an error

func MustReadJSON

func MustReadJSON(t *testing.T, filePath string, v any)

func MustReadYAML

func MustReadYAML(t *testing.T, path string, out any)

func MustWriteFile

func MustWriteFile(t *testing.T, filePath string, content []byte)

func MustWriteJSON

func MustWriteJSON(t *testing.T, filePath string, v any)

func MustWriteYAML

func MustWriteYAML(t *testing.T, path string, data any)

func SetupLocalStack

func SetupLocalStack(ctx context.Context, version string) (*localstack.LocalStackContainer, string, error)

func TxtarToFS

func TxtarToFS(t *testing.T, path string) fs.FS

TxtarToFS reads a txtar file and returns it as an fs.FS.

func VMImageName

func VMImageName(subpath, tag, digest string) string

Types

type DockerClient

type DockerClient struct {
	*client.Client
}

func NewDockerClient

func NewDockerClient(t *testing.T) *DockerClient

func (*DockerClient) ImageCleanLoad

func (c *DockerClient) ImageCleanLoad(t *testing.T, ctx context.Context, archivePath string) string

ImageCleanLoad performs a clean load of a Docker image from a tar archive. It removes any existing images with conflicting RepoTags before loading, ensuring the loaded image has the correct RepoTags from the archive. It automatically registers cleanup via t.Cleanup() to remove the loaded image after the test.

func (*DockerClient) ImageLoad

func (c *DockerClient) ImageLoad(t *testing.T, ctx context.Context, imageFile string) string

ImageLoad loads a Docker image from a tar archive file into the Docker engine. It automatically registers cleanup via t.Cleanup() to remove the loaded image after the test.

func (*DockerClient) ImageRemove

func (c *DockerClient) ImageRemove(t *testing.T, ctx context.Context, imageID string)

Jump to

Keyboard shortcuts

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