testutil

package
v0.68.2 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2025 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 added in v0.50.0

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

func AssertRuleFound added in v0.50.0

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

func AssertRuleNotFailed added in v0.58.0

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

func AssertRuleNotFound added in v0.50.0

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

func CopyDir added in v0.53.0

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 added in v0.54.0

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

func CreateFS added in v0.50.0

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

func DecompressGzip

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

func DecompressSparseGzip added in v0.43.0

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

DecompressSparseGzip decompresses a sparse gzip file for virtual machine image.

func ImageName added in v0.57.0

func ImageName(subpath, tag, digest string) string

func MustMkdirAll added in v0.54.0

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

func MustParseReference added in v0.68.0

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 added in v0.54.0

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

func MustReadYAML added in v0.54.0

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

func MustWriteFile added in v0.54.0

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

func MustWriteJSON added in v0.54.0

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

func MustWriteYAML added in v0.54.0

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

func SetupLocalStack added in v0.50.0

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

func TxtarToFS added in v0.68.0

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

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

func VMImageName added in v0.57.0

func VMImageName(subpath, tag, digest string) string

Types

type DockerClient added in v0.56.0

type DockerClient struct {
	*client.Client
}

func NewDockerClient added in v0.56.0

func NewDockerClient(t *testing.T) *DockerClient

func (*DockerClient) ImageCleanLoad added in v0.68.0

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 added in v0.56.0

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 added in v0.56.0

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