8000 GitHub - rdumont/loki: A simple way to create fakes in Go
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

rdumont/loki

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Loki

A simple way to create fakes in Go

Basic Usage

package example

import "github.com/rdumont/loki"

type TodoAdder interface {
    // Add creates a new todo and returns its position in the list
    Add(description string) int
}

type FakeTodoAdder interface {
    AddCalls    loki.Method
}

func (ta *FakeTodoAdder) Add(description string) int {
    return ta.AddCalls.Receive(description).Get(0)
}
package example

func DoSomething() {
    adder := new(FakeTodoAdder)

    adder.AddCalls.On("some todo").Return(5)

    pos := adder.Add("some todo")
    fmt.Println("Position is", pos)
    // pos == 5
}

About

A simple way to create fakes in Go

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

0