be_struct

package
v1.0.0-rc.8 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: MIT Imports: 6 Imported by: 0

README

be_struct

-- import "."

Usage

func HavingField
func HavingField[StructT any](fieldName string, expectedValue ...any) types.BeMatcher

HavingField succeeds if the actual value is a struct and it has a field with the given name. If an expected value is provided, it also succeeds if the actual value's field has the same value.

Example:

Expect(result).To(be_structs.HavingField[TestStruct]("Field1", "hello1"))
Expect(result).To(be_structs.HavingField[TestStruct]("Field2"))

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HavingField

func HavingField[StructT any](fieldName string, expectedValue ...any) types.BeMatcher

HavingField succeeds if the actual value is a struct of exactly type StructT and it has a field with the given name. If an expected value (raw value or matcher) is provided, the field's value must match it too.

Example:

Expect(result).To(be_struct.HavingField[TestStruct]("Field1", "hello1"))
Expect(result).To(be_struct.HavingField[TestStruct]("Field2"))

This is the generic, compile-time-typed variant: it pins the struct type at the call site. For everyday assertions prefer the root be.HaveField — it needs no type parameter, and supports dotted paths and "Method()" specs. The naming wobble (HaveField vs HavingField) is deliberate: it separates the default matcher from this typed variant.

Types

This section is empty.

Jump to

Keyboard shortcuts

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