rct

package
v1.67.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2026 License: MIT Imports: 8 Imported by: 0

README

Package rct

Пакет rct предназначен для тестирования схемы и валидации удалённой конфигурации, используемой с isp-kit.

Functions

Test[T any](t *testing.T, defaultRemoteConfigPath string, remoteConfig T)

Проверяет, что удалённая конфигурация соответствует сгенерированной JSON-схеме и проходит валидацию.

  • Проверяет отсутствие устаревшего тега valid
  • Проверяет соответствие структуры JSON-схеме
  • Выполняет валидацию значений с помощью validator.Default
FindTag[T any](v T, tag string) bool

Рекурсивно проверяет, содержит ли структура тег с указанным именем.

Usage

Example usage in test
package mypkg_test

import (
	"testing"

	"github.com/txix-open/isp-kit/rct"
)

type RemoteCfg struct {
	Name string `json:"name" validate:"required"`
}

func TestRemoteCfg(t *testing.T) {
	rct.Test(t, "conf/default_remote_config.json", RemoteCfg{})
}

Documentation

Overview

Package rct provides test helpers for remote configuration validation. It validates that configuration structures match their JSON schemas and can be properly unmarshaled from configuration files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindTag

func FindTag[T any](v T, tag string) bool

FindTag recursively searches a type for the specified struct tag. It traverses structs, maps, arrays, and slices to find any field that has the given tag. Returns true if the tag is found.

func Test

func Test[T any](t *testing.T, defaultRemoteConfigPath string, remoteConfig T)

Test validates that the provided configuration structure matches its generated JSON schema and can be properly unmarshaled from the default configuration file. It also verifies that the configuration passes validator tag validation.

The function checks:

  • No deprecated 'valid' tags are present
  • The default configuration file is valid against the generated schema
  • The configuration can be unmarshaled from the file
  • The configuration passes validation

nolint:lll

Types

This section is empty.

Jump to

Keyboard shortcuts

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