Documentation
¶
Overview ¶
Package gentesting provides test utilities for code generation.
Index ¶
- func CaptureOutput(w io.Writer) func()
- func DiscardOutput() func()
- func ExecInDir(target string, command string, args ...string) func(*testing.T)
- func GoBuild(pth string) func(*testing.T)
- func GoExecInDir(target string, args ...string) func(*testing.T)
- func GoModInit(pth string, opts ...GoModOption) func(*testing.T)
- func GoModReplace(pth, src, dst string) func(*testing.T)
- func GoModTidy(pth string) func(*testing.T)
- func SanitizeGoModPath(pth string) string
- type GoModOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CaptureOutput ¶
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 GoExecInDir ¶
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 GoModReplace ¶
func SanitizeGoModPath ¶
Types ¶
type GoModOption ¶
type GoModOption func(o *goModOptions)
func WithGoModuleName ¶
func WithGoModuleName(name string) GoModOption
Click to show internal directories.
Click to hide internal directories.