testutil

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package testutil provides test helpers for msgvault tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertFileContent

func AssertFileContent(t *testing.T, path string, expected string)

AssertFileContent reads the file at path and asserts its content matches expected.

func MustExist

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

MustExist fails the test if the path does not exist or cannot be accessed.

func MustNoErr

func MustNoErr(t *testing.T, err error, msg string)

MustNoErr fails the test immediately if err is non-nil. Use this for setup operations where failure means the test cannot proceed.

func MustNotExist

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

MustNotExist fails the test if the path exists or if there's an error other than "not exist" (e.g., permission denied).

func NewTestStore

func NewTestStore(t *testing.T) *store.Store

NewTestStore creates a temporary database for testing. The database is automatically cleaned up when the test completes.

func ReadFile

func ReadFile(t *testing.T, path string) []byte

ReadFile reads a file and fails the test on error.

func TempDir

func TempDir(t *testing.T) string

TempDir creates a temporary directory for testing. The directory is automatically cleaned up when the test completes.

func WriteFile

func WriteFile(t *testing.T, dir, name string, content []byte) string

WriteFile writes content to a file in the given directory. The name must be a relative path without ".." components to ensure test isolation. Absolute paths or paths that escape dir will fail the test.

Types

This section is empty.

Jump to

Keyboard shortcuts

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