testutil

package
v0.52.2 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

README

Test utilities used in KHI tests

If testuitl needs to depend on non testutil, these should be in dedicated subfolder in testutil.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ForceUpdateGolden = false

Functions

func GlobResultToChildTestName

func GlobResultToChildTestName(filePath string, basePath string) string

* * KHI has many tests using configurations and these configurations are read by glob. * glob result can contain non meaningful relative path and slash.

func GlobTestResources

func GlobTestResources(fileGlob string, ignoredSuffixes []string) []string

func InitTestIO

func InitTestIO()

func MustParseTimeRFC3339

func MustParseTimeRFC3339(timeStr string) time.Time

func MustPlaceTemporalFile

func MustPlaceTemporalFile(filePath, content string) (cleanup func())

MustPlaceTemporalFile write a file at the specified path and returns a function to unlink it for cleaning up.

func MustReadText

func MustReadText(filePath string) string

func MustReadYaml

func MustReadYaml(filePath string) map[string]any

func P

func P[T any](value T) *T

P returns the pointer of given value. This is helper to get the pointer from literal because Go doesn't allow &"foo".

func RemoveSlogTimestampFromLine

func RemoveSlogTimestampFromLine(log string) string

Removes timestamps from slog logs

func ResponseFromString

func ResponseFromString(code int, response string) *http.Response

func VerifyWithGolden

func VerifyWithGolden(t testing.TB, verificationTargetName string, body string)

VerifyWithGolden test if the given body is matching with the golden file saved for each tests under /test/golden/

Types

This section is empty.

Directories

Path Synopsis
gcp

Jump to

Keyboard shortcuts

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