gentesting

package
v0.0.0-...-bb97fcc Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package gentesting provides test utilities for code generation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CaptureOutput

func CaptureOutput(w io.Writer) func()

CaptureOutput captures the standard logger to the passed writer and returns a rollback function. Typical usage:

var buf bytes.Buffer
defer gentest.CaptureOutput(&buf)()

func DiscardOutput

func DiscardOutput() func()

DiscardOutput discards the standard logger and returns a rollback function.

Typical usage:

defer gentest.DiscardOutput()()

func ExecInDir

func ExecInDir(target string, command string, args ...string) func(*testing.T)

func GoBuild

func GoBuild(pth string) func(*testing.T)

func GoExecInDir

func GoExecInDir(target string, args ...string) func(*testing.T)

GoExecInDir executes a go commands from a target current directory.

It returns a test runner func(*testing.T).

Typical usage:

t.Run("should execute mycommand", gentest.GoExecInDir(folder, args))

func GoModInit

func GoModInit(pth string, opts ...GoModOption) func(*testing.T)

func GoModReplace

func GoModReplace(pth, src, dst string) func(*testing.T)

func GoModTidy

func GoModTidy(pth string) func(*testing.T)

func SanitizeGoModPath

func SanitizeGoModPath(pth string) string

Types

type GoModOption

type GoModOption func(o *goModOptions)

func WithGoModuleName

func WithGoModuleName(name string) GoModOption

Jump to

Keyboard shortcuts

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