atesting

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package atesting provides Spy function for easy way to mock dependencies

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Spy

func Spy(v interface{}, dependencies ...interface{})

Spy Function is replacing object field with the one provided in the function as a variadic arguments. Spy Function will detect fully automatically which field could be replaced with the provided one as variadic arguments. As shown inside example package, we are replacing AuditClient with our mock implementation. Example:

Spy(application, &TestAuditClient{})

Or this is equivalent of doing it manually

application.UserSvc().SetAuditClient(&TestAuditClient{})

When we don't use Spy function, we need to provide Getter method UserSvc() in order to access unexported userSvc field. For more information take a look at test file in example package. Parameters of Spy function:

  • `v` : pointer to structure inside which spy object will be injected
  • `dependencies` : this is variadic argument, pointer to mocked structures which are gonna be injected

Types

This section is empty.

Jump to

Keyboard shortcuts

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