birb

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2025 License: MPL-2.0 Imports: 2 Imported by: 0

README

:imagesdir: docs/assets
= Birb

image::switch-banner.jpg[]

== Overview

This is a mocking library for Go that provides a simple straightforward way to create, use,
and validate using mocks generated by https://github.com/vektra/mockery[mockery].

== Inspiration

This was inspired by https://site.mockito.org/[Mockito] for Java,
https://phake.readthedocs.io/en/latest/[Phake] for PHP,
and another go mocking library https://github.com/ovechkin-dm/mockio[mockio].

https://github.com/ovechkin-dm/mockio[mockio] is a great library, but it didn't work well with
https://onsi.github.io/ginkgo/[Ginkgo] and https://onsi.github.io/gomega/[Gomega].
mockio also focused on mocking dynamically, this library focuses on mocking interfaces with generated code.

Documentation

Overview

Package birb provides a simple interface for creating and verifying mock interactions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Anything

func Anything() matchers.Matcher

Anything is a matcher that matches any SINGULAR value. This is useful when you don't care about the specific value passed to a method.

func AtLeast

func AtLeast(n int) *handlers.CallVerifier

AtLeast is a helper function to create verifiers that expect the method to be called at least n times.

func AtMost

func AtMost(n int) *handlers.CallVerifier

AtMost is a helper function to create verifiers that expect the method to be called at most n times.

func Captor

func Captor() matchers.Captor

Captor is a matcher that captures the value passed to a method. This is useful when you want to verify the value passed to a method after it has been called.

func CopyIntoFunc

func CopyIntoFunc[T any](toCopy T, copyFunc matchers.CopyIntoFunc[T]) matchers.CopyInto

CopyIntoFunc

func DeepCopyInto

func DeepCopyInto[T matchers.DeepCopyInto[T]](toCopy T) matchers.CopyInto

DeepCopyInto

func Freeze

func Freeze[Mock Birb](mock Mock)

Freeze verifies that no methods will be called on the Birb instance.

func Never

func Never() *handlers.CallVerifier

Never helper function to create a verifier that expects the method to have never been called.

func Once

func Once() *handlers.CallVerifier

Once helper function to create a verifier that expects the method to be called exactly once.

func ShallowCopyInto

func ShallowCopyInto[T any](toCopy *T) matchers.CopyInto

ShallowCopyInto is a convenience function to create a CopyInto matcher that copies the value from a pointer.

func Times

func Times(n int) *handlers.CallVerifier

Times verify that a method is called exactly n times.

func Twice

func Twice() *handlers.CallVerifier

Twice helper function to create a verifier that expects the method to be called exactly twice.

func Verify

func Verify[Mock Birb](mock Mock, v *handlers.CallVerifier) Mock

Verify will verify that the Birb instance has been called as expected.

func VerifyNeverCalled

func VerifyNeverCalled[Mock Birb](mock Mock)

VerifyNeverCalled verifies that no methods were called on the Birb instance that were not already verified.

func VerifyNoOtherInteractions

func VerifyNoOtherInteractions[Mock Birb](mock Mock)

VerifyNoOtherInteractions verifies that no methods were called on the Birb instance that were not already verified.

func WhenCalling

func WhenCalling(ans *handlers.BirbMocker) *handlers.BirbMocker

WhenCalling is the API to use for setting up method stubs on a Birb mock.

func WithAnyArgs

func WithAnyArgs() matchers.Matcher

WithAnyArgs is a matcher that matches any values. This is useful when you don't care about the specific value passed to a method.

Types

type Birb

type Birb interface {
	BirbHandler() *handlers.Handler
}

Birb is an interface that defines the methods required for a Birb mock.

Directories

Path Synopsis
cmd
birb command
Code generated by cmd/birb/birbTemplates.sh; DO NOT EDIT.
Code generated by cmd/birb/birbTemplates.sh; DO NOT EDIT.
internal

Jump to

Keyboard shortcuts

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