tst

package
v1.2.5 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package tst provides helper utilities used by tests in this repository.

The helpers include file-content comparisons, stdout capture, and text normalization helpers for stable assertions across platforms.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertEqualFiles added in v0.27.8

func AssertEqualFiles(t *testing.T, fn0, fn1 string)

AssertEqualFiles fails test if content is NOT equal

func CaptureStdOut

func CaptureStdOut(f func()) string

CaptureStdOut captures stdout and returns it as string.

func EqualLines

func EqualLines(tb testing.TB, exp, act string)

EqualLines compares exp and act line by line ignoring line endings and leading/trailing spaces.

func EqualTextFiles

func EqualTextFiles(t *testing.T, fSys *afero.Afero, fn0, fn1 string)

EqualTextFiles fails test if lines in fn0 & fn1 NOT equal. Line endings are ignored

func NormalizeMapString added in v1.1.0

func NormalizeMapString(s string) string

NormalizeMapString trims insignificant whitespace in Go-style map[string]struct formatting.

It is useful for comparing stringified maps where `fmt.Sprint(map)` includes formatting inconsistencies such as:

  • trailing spaces after struct fields (e.g., "{t11 s11 }")
  • extra spaces between map entries (e.g., "12:{... }")

This behavior may vary subtly between Go versions (e.g., Go 1.18 vs 1.20+), where `fmt.Sprint` preserves more internal spacing from struct formatting.

normalizeMapString helps produce stable, human-readable string output suitable for comparison in tests without altering the logical content.

func TempFileName

func TempFileName(pattern string) (s string)

TempFileName returns a temporary file name based on pattern. The file is created and deleted and only the name is delivered. The pattern should contain at least an asterisks. Example: "myFile-*.bin"

Types

This section is empty.

Jump to

Keyboard shortcuts

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