tester

package
v0.1.90 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

README

Conversions Tester

Validates that a module's OpenAPI configuration conversions are well-formed and that they transform settings as expected.

Overview

The Conversions Tester runs against every module that ships an openapi/conversions/ directory. It checks the conversion files for validity, makes sure the declared config version stays in sync with the conversions, and replays any testcases through the converter to confirm they produce the expected output.

It is invoked through the dmt test conversions command.

A module is applicable (i.e. tested) only when it has an openapi/conversions/ directory; other modules are skipped.

Checks

  • ✅ The latest conversion version matches x-config-version in openapi/config-values.yaml
  • x-config-version is set whenever conversions exist
  • ✅ All conversion files in openapi/conversions/ are valid
  • ✅ Each testcase in openapi/conversions/testcases.yaml converts its input settings into the expected output

File Structure

openapi/
├── config-values.yaml          # must declare x-config-version
└── conversions/
    ├── v2.yaml                  # conversion to version 2 (first conversion)
    ├── v3.yaml                  # conversion to version 3
    └── testcases.yaml           # optional: conversion testcases

Conversion File

# openapi/conversions/v2.yaml
version: 2
conversions:
  - del(.auth.password)
description:
  en: "v2"
  ru: "v2"

Testcases File

Each testcase declares the source and target versions, the input settings, and the expected result after conversion.

# openapi/conversions/testcases.yaml
testcases:
  - name: "should delete auth.password on 1 to 2"
    currentVersion: 1
    expectedVersion: 2
    settings: |
      auth:
        password: secret
    expected: |
      auth: {}

A module without testcases.yaml still has its conversion files and version validated.

Usage

# Test conversions for all modules under the current directory
dmt test conversions

# Test a single module
dmt test conversions ./modules/my-module

Documentation

Index

Constants

View Source
const (
	ID = "conversions"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Tester

type Tester struct {
	ErrorList *pkgerrors.TestErrorsList
	// contains filtered or unexported fields
}

func New

func New(errorList *pkgerrors.TestErrorsList) *Tester

func (*Tester) Desc

func (t *Tester) Desc() string

func (*Tester) Name

func (t *Tester) Name() string

func (*Tester) Run

func (t *Tester) Run(modulePath string) bool

Run executes the conversions tester against the given module path. Returns true if the tester was applicable to this module.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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