mock

package module
v0.0.0-...-e3653cc Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

README

This repo contains 2 packages:

  1. fuse
  2. mock

Goals:

  1. Minimal imports - Only one import (fuse) during configuration.
  2. Non-intrusive - References to the package fuse should be in just startup code.
  3. Small API - just enough to get work done.
  4. Minimal footprint/low overhead - no complicated setup code required.

For a full usage example of these 2 packages please refer to repo Guide to usage of library fuse

Package fuse

Features:

Dependency Injection pattern - primarily used for stateless components, all components are singletons.

  1. Register components.
  2. Inject stateless component dependencies.

Resource Locator pattern - primarily used for stateful components, all components are prototypes.

  1. Register components.
  2. A "Finder" function is provided to get a new copy of the component.
  3. Inject stateless component dependencies.

Constraints:

  1. Components can only be registered as pointers.
  2. Components dependencies can either be through interfaces or pointers to structs.

Package mock

mock library generates mock code for all the dependencies of a component.

For a full usage example of these 2 packages please refer to repo Guide to usage of library fuse

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Component

type Component struct {
	// Component key, required
	Name string
	// Instance is pointer to component
	Instance interface{}
	// Stateless of stateful
	//Stateless bool
	//Base path to generate mocks
	Basepath string
}

type Mock

type Mock interface {
	// Register a slice of components
	Register(entries []fuse.Entry) []error
	// Generate mocks
	Generate() []error
}

func New

func New(basepath string) Mock

New initializes the builder for mocks

Jump to

Keyboard shortcuts

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