toolcacher

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2019 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package toolcacher provides a binary caching mechanism.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cacher

type Cacher interface {
	// Get finds a cached tool path which satisfies the passed pkgName and version.
	// If it is not cached, Get builds a new one.
	Get(ctx context.Context, pkgName, version string) (path string, err error)
	// Clear removes all cached tools.
	Clear(ctx context.Context) error
}

func New

func New(gocmd gocmd.Command) (Cacher, error)

type CacherMock

type CacherMock struct {
	// ClearFunc mocks the Clear method.
	ClearFunc func(ctx context.Context) error

	// GetFunc mocks the Get method.
	GetFunc func(ctx context.Context, pkgName string, version string) (string, error)
	// contains filtered or unexported fields
}

CacherMock is a mock implementation of Cacher.

    func TestSomethingThatUsesCacher(t *testing.T) {

        // make and configure a mocked Cacher
        mockedCacher := &CacherMock{
            ClearFunc: func(ctx context.Context) error {
	               panic("mock out the Clear method")
            },
            GetFunc: func(ctx context.Context, pkgName string, version string) (string, error) {
	               panic("mock out the Get method")
            },
        }

        // use mockedCacher in code that requires Cacher
        // and then make assertions.

    }

func (*CacherMock) Clear

func (mock *CacherMock) Clear(ctx context.Context) error

Clear calls ClearFunc.

func (*CacherMock) ClearCalls

func (mock *CacherMock) ClearCalls() []struct {
	Ctx context.Context
}

ClearCalls gets all the calls that were made to Clear. Check the length with:

len(mockedCacher.ClearCalls())

func (*CacherMock) Get

func (mock *CacherMock) Get(ctx context.Context, pkgName string, version string) (string, error)

Get calls GetFunc.

func (*CacherMock) GetCalls

func (mock *CacherMock) GetCalls() []struct {
	Ctx     context.Context
	PkgName string
	Version string
}

GetCalls gets all the calls that were made to Get. Check the length with:

len(mockedCacher.GetCalls())

Jump to

Keyboard shortcuts

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