helper

package
v0.2.15 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2025 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloneProtoMessage

func CloneProtoMessage(t *testing.T, src proto.Message) proto.Message

CloneProtoMessage creates a deep copy of a protobuf message.

func LoadConfigFromFile

func LoadConfigFromFile(t *testing.T, configPath string, v proto.Message)

LoadConfigFromFile loads a configuration from the specified file path into a proto.Message using the framework's config package.

func LoadConfigFromFileWithViper added in v0.2.7

func LoadConfigFromFileWithViper(t *testing.T, path string, msg proto.Message)

LoadConfigFromFileWithViper loads a config file into a protobuf message.

func LoadMiddleware added in v0.2.7

func LoadMiddleware(t *testing.T, configPath string) (*middlewarev1.Middlewares, error)

LoadMiddleware loads and parses a middleware configuration file using the framework's config.

func LoadYAMLConfig

func LoadYAMLConfig(filename string) ([]byte, error)

LoadYAMLConfig loads a YAML configuration file and converts it to a JSON format byte array.

func SaveConfigToFileWithViper added in v0.2.7

func SaveConfigToFileWithViper(t *testing.T, msg proto.Message, path string, formatName string)

SaveConfigToFileWithViper saves a protobuf message to a file in the specified format.

func SetupIntegrationTest added in v0.2.7

func SetupIntegrationTest(t *testing.T) func()

SetupIntegrationTest sets up the environment for integration tests. It changes the working directory to the runtime module's root, allowing tests to use consistent relative paths for configuration files. It returns a cleanup function that restores the original working directory.

func WithMockData added in v0.2.7

func WithMockData(data map[string]string) func(*MockConsulSource)

WithMockData provides mock data for MockConsulSource. It expects string values, which will be treated as YAML content. This function maintains backward compatibility with the original signature.

func WithMockDataJSON added in v0.2.7

func WithMockDataJSON(data map[string]interface{}) options.Option

WithMockDataJSON provides mock data for MockConsulSource, marshaling values to JSON.

func WithMockDataString added in v0.2.7

func WithMockDataString(data map[string]string, format string) func(*MockConsulSource)

WithMockDataString provides mock data for MockConsulSource, allowing specification of the format for string values.

func WithMockDataYAML added in v0.2.7

func WithMockDataYAML(data map[string]interface{}) options.Option

WithMockDataYAML provides mock data for MockConsulSource, marshaling values to YAML.

Types

type MockConsulSource added in v0.2.7

type MockConsulSource struct {
	// contains filtered or unexported fields
}

MockConsulSource is a mock implementation of runtimeconfig.Source for Consul.

func (*MockConsulSource) Load added in v0.2.7

Load returns the mock data as KeyValue pairs.

func (*MockConsulSource) NewSource added in v0.2.7

func (m *MockConsulSource) NewSource(config *sourcev1.SourceConfig, opts ...options.Option) (kratosconfig.Source,
	error)

NewSource creates a new instance of MockConsulSource.

func (*MockConsulSource) String added in v0.2.7

func (m *MockConsulSource) String() string

String returns the name of the mock source.

func (*MockConsulSource) Watch added in v0.2.7

Watch is not implemented for the mock source.

Jump to

Keyboard shortcuts

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