Documentation
¶
Index ¶
- func BuildStatements(body *ast.BlockStmt) []ast.Stmt
- func ContainerReads(block *ast.BlockStmt, locals map[string]bool) map[string]bool
- func GuardedFields(cond ast.Expr) []string
- func ImportAliases(file *ast.File) map[string]string
- func InitAppWith(file *ast.File) *ast.FuncDecl
- func InitAppWithBody(file *ast.File) *ast.BlockStmt
- func Locals(body *ast.BlockStmt) map[string]bool
- func PrologueAssignment(stmt ast.Stmt) (field, seam string, ok bool)
- func QualifiedBy(expr ast.Expr, ident string) (string, bool)
- type Container
- type EnvRead
- type Seam
- type TypeRef
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildStatements ¶
The statements of InitAppWith and of every buildX := diogenBuild(name, func…) in it: diogen builds each field inside a closure of its own.
func ContainerReads ¶
An assignment target is a write, the closers slice is bookkeeping the generator adds to every seam alike, and a local stands for a field.
func GuardedFields ¶
Recursive, so a guard carrying a branch condition alongside still resolves.
func ImportAliases ¶
diogen writes an explicit alias on every non-stdlib import, so the fallback to the last path segment is for a file that was not written by it.
func Locals ¶
The locals that hold a value of a type the container cannot name: x := diogenZero1(lib.NewX).
func PrologueAssignment ¶
container.x = replacements.X
Types ¶
type Container ¶
Located by the //go:generate directive: the path is written there already, and a copy in waffle.yaml would be a second thing to keep in sync.
func DiscoverContainers ¶
A slice, because a service may have two containers.
type EnvRead ¶
type EnvRead struct {
Reader string // Value, NeedArray, MustJson…
Key string
Type ast.Expr // the call's one type argument; nil without exactly one
Call *ast.CallExpr
Pos token.Position
Imports map[string]string // the file's, alias -> path
}
EnvRead is one call of a reader of gitlab.com/gorib/env whose key is a literal.
type Seam ¶
type Seam struct {
Field string
Types []TypeRef
// Replacing a leaf leaves the whole service under test; replacing an interior
// seam cuts out everything below it.
Leaf bool
}
More than one type means diogen merged registrations sharing the field, and the entry is a composite interface that no single mock satisfies.