Releases: ryanmoran/faux
Releases · ryanmoran/faux
Version 0.10.0
Supports interfaces that pass functions as arguments
// example_test.go
package example_test
//go:generate faux --interface example --output fakes/example.com
type example interface {
Example(func(string) err) func(int) bool
}
// fakes/example.go
package fakes
import "sync"
type Example struct {
ExampleCall struct {
sync.Mutex
CallCount int
Receives struct {
FuncStringError func(string) error
}
Returns struct {
FuncIntBool func(int) bool
}
Stub func(func(string) error) func(int) bool
}
}
func (f *Example) Example(param1 func(string) error) func(int) bool {
f.ExampleCall.Lock()
defer f.ExampleCall.Unlock()
f.ExampleCall.CallCount++
f.ExampleCall.Receives.FuncStringError = param1
if f.ExampleCall.Stub != nil {
return f.ExampleCall.Stub(param1)
}
return f.ExampleCall.Returns.FuncIntBool
}
Version 0.9.0
Adds support for method stubs
package example_test
//go:generate faux --interface example --output fakes/example.com
type example interface {
Example()
}
func TestExample() {
fake := &fakes.Example{}
fake.ExampleCall.Stub = func() {
fmt.Println("this is an example output")
}
fake.Example() // outputs "this is an example call"
}
Version 0.8.0
Now with more sync.Mutex
Version 0.7.0
Rewrites the parsing and rendering internals.
Makes working with ambiguous interface parameters much nicer.
Version 0.6.0
Handles variadic arguments correctly.
Version 0.5.0
Fixes a bug where fake output files were not being truncated before being rewritten.
Version 0.4.0
Fixes up generation for interfaces that references packages in GOPATH or modules.
Version 0.3.0
Fixes some weird edge cases where type or field names are elided.
Version 0.2.0
Adds support for GOPATH interfaces.
You can now call faux
with an interface that is declared elsewhere on your GOPATH. For example:
faux --package github.com/pivotal-cf/jhanda --interface Command --output command.go
Version 0.1.0
Yay! The first release.