testutil

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package testutil provides common testing utilities for Sietch

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertDirExists

func AssertDirExists(t *testing.T, path string)

AssertDirExists checks if a directory exists and fails the test if it doesn't

func AssertFileContains

func AssertFileContains(t *testing.T, path, expectedContent string)

AssertFileContains checks if a file contains specific content

func AssertFileExists

func AssertFileExists(t *testing.T, path string)

AssertFileExists checks if a file exists and fails the test if it doesn't

func AssertFileNotExists

func AssertFileNotExists(t *testing.T, path string)

AssertFileNotExists checks if a file doesn't exist and fails the test if it does

func AssertFileSize

func AssertFileSize(t *testing.T, path string, expectedSize int64)

AssertFileSize checks if a file has the expected size

func CaptureOutput

func CaptureOutput(t *testing.T, fn func()) (stdout, stderr string)

CaptureOutput captures stdout/stderr for testing CLI commands

func CompareBytes

func CompareBytes(t *testing.T, expected, actual []byte, context string)

CompareBytes compares two byte slices and reports differences

func CreateTestFile

func CreateTestFile(t *testing.T, dir, filename, content string) string

CreateTestFile creates a test file with specified content

func CreateTestFileWithSize

func CreateTestFileWithSize(t *testing.T, dir, filename string, size int64) string

CreateTestFileWithSize creates a test file with random content of specified size

func CreateTestRSAKeyPair

func CreateTestRSAKeyPair(t *testing.T, bits int) (*rsa.PrivateKey, *rsa.PublicKey)

CreateTestRSAKeyPair creates an RSA key pair for testing

func CreateTestVaultConfig

func CreateTestVaultConfig(t *testing.T, vaultName string) *config.VaultConfig

CreateTestVaultConfig creates a basic vault configuration for testing

func CreateTestVaultStructure

func CreateTestVaultStructure(t *testing.T, vaultPath string)

CreateTestVaultStructure creates a basic vault directory structure for testing

func GenerateTestData

func GenerateTestData(size int) []byte

GenerateTestData generates test data of specified size for benchmarking

func SkipIfShort

func SkipIfShort(t *testing.T, reason string)

SkipIfShort skips the test if running in short mode

func TempDir

func TempDir(t testing.TB, prefix string) string

TempDir creates a temporary directory for testing

Types

type MockConfig

type MockConfig struct {
	VaultPath string
	Config    *config.VaultConfig
}

MockConfig creates a mock configuration for testing

func NewMockConfig

func NewMockConfig(t *testing.T, vaultName string) *MockConfig

NewMockConfig creates a new mock configuration

func (*MockConfig) SetupTestVault

func (mc *MockConfig) SetupTestVault(t *testing.T)

SetupTestVault creates a complete test vault with structure and config

Jump to

Keyboard shortcuts

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