common

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package common provides helpers for writing tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeSlice

func MakeSlice[S ~[]E, E any](out *S, size int)

MakeSlice creates a new slice in place.

Useful for initializing slices of anonymous structs in tests.

type Config struct {
	Endpoints []struct {
		Host string
		Port uint
	}
}

var cfg Config
MakeSlice(&cfg.Endpoints, 10)

func NewViper

func NewViper() *viper.Viper

NewViper creates a new viper.Viper instance configured for testing.

func RunForEachSource

func RunForEachSource(t *testing.T, name string, f func(t *testing.T, v *viper.Viper))

RunForEachSource runs a test for each config source: YAML, JSON, and ENV.

func ViperReadFile

func ViperReadFile(tb testing.TB, v *viper.Viper, file string)

ViperReadFile reads a config file into the given Viper instance.

Types

type LogDestination

type LogDestination struct {
	Type string
	File string
	Host string
	Port uint
}

LogDestination is a custom type that implements core.ConfigLoader.

func (*LogDestination) Load

func (d *LogDestination) Load(v *core.Viper) (facts core.Facts, err error)

Load implements core.ConfigLoader.

type LogLevel

type LogLevel string

LogLevel is a custom type that implements core.StringParser.

func (*LogLevel) Parse

func (l *LogLevel) Parse(s string) error

Parse implements core.StringParser.

Jump to

Keyboard shortcuts

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