Skip to content

Releases: ryanmoran/faux

Version 0.10.0

06 May 18:51
Compare
Choose a tag to compare

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

06 May 15:24
Compare
Choose a tag to compare

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

03 May 16:00
Compare
Choose a tag to compare

Now with more sync.Mutex

Version 0.7.0

03 May 15:14
Compare
Choose a tag to compare

Rewrites the parsing and rendering internals.

Makes working with ambiguous interface parameters much nicer.

Version 0.6.0

19 Apr 14:06
Compare
Choose a tag to compare

Handles variadic arguments correctly.

Version 0.5.0

15 Apr 14:05
Compare
Choose a tag to compare

Fixes a bug where fake output files were not being truncated before being rewritten.

Version 0.4.0

24 Mar 21:25
Compare
Choose a tag to compare

Fixes up generation for interfaces that references packages in GOPATH or modules.

Version 0.3.0

07 Mar 16:58
Compare
Choose a tag to compare

Fixes some weird edge cases where type or field names are elided.

Version 0.2.0

07 Mar 15:41
Compare
Choose a tag to compare

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

04 Mar 21:39
Compare
Choose a tag to compare

Yay! The first release.