genparams

package
v0.0.0-...-683b059 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2022 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Overview

Package genparams provides utilities to generate large Tast test metadata.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Ensure

func Ensure(t TestingT, file, params string)

Ensure ensures that parameterized test parameters in a test metadata are up-to-date.

file is a file name of a .go file containing a Tast test definition (i.e. testing.AddTest call). params is a Go literal expression as a string that represents test parameters.

If TAST_GENERATE_UPDATE environment variable is not set, this function checks if parameterized test parameters in file matches with params. If any mismatch is found, it reports a test error with a message prompting users to regenerate parameterized test parameters.

If TAST_GENERATE_UPDATE environment variable is set, this function rewrites the testing.Test literal in file with params.

func Template

func Template(t TestingT, text string, data interface{}) string

Template is a utility function to render a Go template into a string in a single call.

Go's standard template engine is used to render a template string. See https://godoc.org/text/template for the template syntax.

This function also installs a few helper function that can be called inside templates:

fmt(v interface{}) string - Formats v in a Go syntax. Supported types are
  boolean, integer, float, string, slice of supported types, map of
  supported types.

Types

type TestingT

type TestingT interface {
	Helper()
	Logf(format string, args ...interface{})
	Errorf(format string, args ...interface{})
	Fatalf(format string, args ...interface{})
}

TestingT is a subset of testing.T. Exported functions in this package take TestingT instead of testing.T to allow unit-testing.

Jump to

Keyboard shortcuts

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