Documentation ¶
Overview ¶
Package testutils implements helper functions for frequently needed functionality in tests.
Index ¶
- Constants
- func GenerateTempCertificate(t *testing.T, path string)
- func LoadWithUpdateFromGolden(t *testing.T, data string, opts ...Option) string
- func LoadWithUpdateFromGoldenYAML[E any](t *testing.T, got E, opts ...Option) E
- func Path(t *testing.T) string
- func ReplaceFileWithDir(t *testing.T, path string, msg string, args ...any)
- func TestFamilyPath(t *testing.T) string
- func TestFixturePath(t *testing.T) string
- func UpdateEnabled() bool
- type Option
- type Set
Constants ¶
const ( // UpdateGoldenFilesEnv is the environment variable used to indicate go test that // the golden files should be overwritten with the current test results. UpdateGoldenFilesEnv = `TESTS_UPDATE_GOLDEN` )
Variables ¶
This section is empty.
Functions ¶
func GenerateTempCertificate ¶
GenerateTempCertificate generates a self-signed certificate valid for one hour. Both the certificate and the private key are stored in the specified path.
func LoadWithUpdateFromGolden ¶
LoadWithUpdateFromGolden loads the element from a plaintext golden file. It will update the file if the update flag is used prior to loading it.
func LoadWithUpdateFromGoldenYAML ¶
LoadWithUpdateFromGoldenYAML load the generic element from a YAML serialized golden file. It will update the file if the update flag is used prior to deserializing it.
func ReplaceFileWithDir ¶
ReplaceFileWithDir removes a file and creates a directory with the same path. Useful to break file reads and assert on the errors.
func TestFamilyPath ¶
TestFamilyPath returns the path of the dir for storing fixtures and other files related to the test.
func TestFixturePath ¶
TestFixturePath returns the path of the dir or file for storing fixture specific to the subtest name.
Types ¶
type Option ¶
type Option func(*goldenOptions)
Option is a supported option reference to change the golden files comparison.
func WithGoldenPath ¶
WithGoldenPath overrides the default path for golden files used.
type Set ¶
type Set[T comparable] struct { // contains filtered or unexported fields }
Set is a simple thread-safe implementation of an unordered set. Useful for testing.