Skip to content

Commit

Permalink
Merge pull request #14 from percolate/always-save-invocations
Browse files Browse the repository at this point in the history
Save Invocations Early
  • Loading branch information
kevinbirch authored Mar 13, 2018
2 parents ff2060d + 8d775af commit afaee97
Show file tree
Hide file tree
Showing 16 changed files with 33 additions and 64 deletions.
2 changes: 1 addition & 1 deletion VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.0
1.0.1
2 changes: 1 addition & 1 deletion template.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ func (f *Fake{{.Name}}) Reset() {
{{range $m := .Methods}}
{{with $f := gensym}}func ({{$f}} *Fake{{$m.Interface}}) {{$m.Name}}({{$m.ParametersDeclaration}}) ({{$m.ResultsDeclaration}}) {
invocation := new({{$m.Interface}}{{$m.Name}}Invocation)
{{$f}}.{{$m.Name}}Calls = append({{$f}}.{{$m.Name}}Calls, invocation)
{{if $m.Parameters}}{{range $m.Parameters}} invocation.Parameters.{{.TitleCase}} = {{.Name}}
{{end}}{{end}}
Expand All @@ -114,7 +115,6 @@ func (f *Fake{{.Name}}) Reset() {
{{end}}
{{if $m.Results}}{{range $m.Results}}invocation.Results.{{.TitleCase}} = {{.Name}}
{{end}}{{end}}
{{$f}}.{{$m.Name}}Calls = append({{$f}}.{{$m.Name}}Calls, invocation)
return
}{{end}}
Expand Down
12 changes: 4 additions & 8 deletions testdata/array/array.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,12 @@ func (f *FakeArray) Reset() {

func (_f1 *FakeArray) ArrayParameter(ident1 [3]string) {
invocation := new(ArrayArrayParameterInvocation)
_f1.ArrayParameterCalls = append(_f1.ArrayParameterCalls, invocation)

invocation.Parameters.Ident1 = ident1

_f1.ArrayParameterHook(ident1)

_f1.ArrayParameterCalls = append(_f1.ArrayParameterCalls, invocation)

return
}

Expand Down Expand Up @@ -266,13 +265,12 @@ func (_f5 *FakeArray) AssertArrayParameterCalledOnceWith(t ArrayTestingT, ident1

func (_f6 *FakeArray) ArrayReturn() (ident1 [3]string) {
invocation := new(ArrayArrayReturnInvocation)
_f6.ArrayReturnCalls = append(_f6.ArrayReturnCalls, invocation)

ident1 = _f6.ArrayReturnHook()

invocation.Results.Ident1 = ident1

_f6.ArrayReturnCalls = append(_f6.ArrayReturnCalls, invocation)

return
}

Expand Down Expand Up @@ -330,13 +328,12 @@ func (f *FakeArray) AssertArrayReturnCalledN(t ArrayTestingT, n int) {

func (_f7 *FakeArray) SliceParameter(ident1 []string) {
invocation := new(ArraySliceParameterInvocation)
_f7.SliceParameterCalls = append(_f7.SliceParameterCalls, invocation)

invocation.Parameters.Ident1 = ident1

_f7.SliceParameterHook(ident1)

_f7.SliceParameterCalls = append(_f7.SliceParameterCalls, invocation)

return
}

Expand Down Expand Up @@ -449,13 +446,12 @@ func (_f11 *FakeArray) AssertSliceParameterCalledOnceWith(t ArrayTestingT, ident

func (_f12 *FakeArray) SliceReturn() (ident1 []string) {
invocation := new(ArraySliceReturnInvocation)
_f12.SliceReturnCalls = append(_f12.SliceReturnCalls, invocation)

ident1 = _f12.SliceReturnHook()

invocation.Results.Ident1 = ident1

_f12.SliceReturnCalls = append(_f12.SliceReturnCalls, invocation)

return
}

Expand Down
15 changes: 5 additions & 10 deletions testdata/channeler/channeler.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,15 +183,14 @@ func (f *FakeChanneler) Reset() {

func (_f1 *FakeChanneler) Channel(ident1 chan int) (ident2 chan int) {
invocation := new(ChannelerChannelInvocation)
_f1.ChannelCalls = append(_f1.ChannelCalls, invocation)

invocation.Parameters.Ident1 = ident1

ident2 = _f1.ChannelHook(ident1)

invocation.Results.Ident2 = ident2

_f1.ChannelCalls = append(_f1.ChannelCalls, invocation)

return
}

Expand Down Expand Up @@ -317,15 +316,14 @@ func (_f6 *FakeChanneler) ChannelResultsForCall(ident1 chan int) (ident2 chan in

func (_f7 *FakeChanneler) ChannelReceive(ident1 <-chan int) (ident2 <-chan int) {
invocation := new(ChannelerChannelReceiveInvocation)
_f7.ChannelReceiveCalls = append(_f7.ChannelReceiveCalls, invocation)

invocation.Parameters.Ident1 = ident1

ident2 = _f7.ChannelReceiveHook(ident1)

invocation.Results.Ident2 = ident2

_f7.ChannelReceiveCalls = append(_f7.ChannelReceiveCalls, invocation)

return
}

Expand Down Expand Up @@ -451,15 +449,14 @@ func (_f12 *FakeChanneler) ChannelReceiveResultsForCall(ident1 <-chan int) (iden

func (_f13 *FakeChanneler) ChannelSend(ident1 chan<- int) (ident2 chan<- int) {
invocation := new(ChannelerChannelSendInvocation)
_f13.ChannelSendCalls = append(_f13.ChannelSendCalls, invocation)

invocation.Parameters.Ident1 = ident1

ident2 = _f13.ChannelSendHook(ident1)

invocation.Results.Ident2 = ident2

_f13.ChannelSendCalls = append(_f13.ChannelSendCalls, invocation)

return
}

Expand Down Expand Up @@ -585,15 +582,14 @@ func (_f18 *FakeChanneler) ChannelSendResultsForCall(ident1 chan<- int) (ident2

func (_f19 *FakeChanneler) ChannelPointer(ident1 *chan int) (ident2 *chan int) {
invocation := new(ChannelerChannelPointerInvocation)
_f19.ChannelPointerCalls = append(_f19.ChannelPointerCalls, invocation)

invocation.Parameters.Ident1 = ident1

ident2 = _f19.ChannelPointerHook(ident1)

invocation.Results.Ident2 = ident2

_f19.ChannelPointerCalls = append(_f19.ChannelPointerCalls, invocation)

return
}

Expand Down Expand Up @@ -719,15 +715,14 @@ func (_f24 *FakeChanneler) ChannelPointerResultsForCall(ident1 *chan int) (ident

func (_f25 *FakeChanneler) ChannelInterface(ident1 chan interface{}) (ident2 chan interface{}) {
invocation := new(ChannelerChannelInterfaceInvocation)
_f25.ChannelInterfaceCalls = append(_f25.ChannelInterfaceCalls, invocation)

invocation.Parameters.Ident1 = ident1

ident2 = _f25.ChannelInterfaceHook(ident1)

invocation.Results.Ident2 = ident2

_f25.ChannelInterfaceCalls = append(_f25.ChannelInterfaceCalls, invocation)

return
}

Expand Down
9 changes: 3 additions & 6 deletions testdata/embedder/embedder.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,12 @@ func (f *FakeEmbedder) Reset() {

func (_f1 *FakeEmbedder) String() (ident5 string) {
invocation := new(EmbedderStringInvocation)
_f1.StringCalls = append(_f1.StringCalls, invocation)

ident5 = _f1.StringHook()

invocation.Results.Ident5 = ident5

_f1.StringCalls = append(_f1.StringCalls, invocation)

return
}

Expand Down Expand Up @@ -196,15 +195,14 @@ func (f *FakeEmbedder) AssertStringCalledN(t EmbedderTestingT, n int) {

func (_f2 *FakeEmbedder) Embed(ident1 string) (ident2 string) {
invocation := new(EmbedderEmbedInvocation)
_f2.EmbedCalls = append(_f2.EmbedCalls, invocation)

invocation.Parameters.Ident1 = ident1

ident2 = _f2.EmbedHook(ident1)

invocation.Results.Ident2 = ident2

_f2.EmbedCalls = append(_f2.EmbedCalls, invocation)

return
}

Expand Down Expand Up @@ -330,15 +328,14 @@ func (_f7 *FakeEmbedder) EmbedResultsForCall(ident1 string) (ident2 string, foun

func (_f8 *FakeEmbedder) Other(ident1 string) (ident2 string) {
invocation := new(EmbedderOtherInvocation)
_f8.OtherCalls = append(_f8.OtherCalls, invocation)

invocation.Parameters.Ident1 = ident1

ident2 = _f8.OtherHook(ident1)

invocation.Results.Ident2 = ident2

_f8.OtherCalls = append(_f8.OtherCalls, invocation)

return
}

Expand Down
6 changes: 2 additions & 4 deletions testdata/funcer/funcer.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,12 @@ func (f *FakeFuncer) Reset() {

func (_f1 *FakeFuncer) FuncParameter(ident1 func(string) string) {
invocation := new(FuncerFuncParameterInvocation)
_f1.FuncParameterCalls = append(_f1.FuncParameterCalls, invocation)

invocation.Parameters.Ident1 = ident1

_f1.FuncParameterHook(ident1)

_f1.FuncParameterCalls = append(_f1.FuncParameterCalls, invocation)

return
}

Expand Down Expand Up @@ -224,13 +223,12 @@ func (_f5 *FakeFuncer) AssertFuncParameterCalledOnceWith(t FuncerTestingT, ident

func (_f6 *FakeFuncer) FuncReturn() (ident1 func(string) string) {
invocation := new(FuncerFuncReturnInvocation)
_f6.FuncReturnCalls = append(_f6.FuncReturnCalls, invocation)

ident1 = _f6.FuncReturnHook()

invocation.Results.Ident1 = ident1

_f6.FuncReturnCalls = append(_f6.FuncReturnCalls, invocation)

return
}

Expand Down
3 changes: 1 addition & 2 deletions testdata/importer/importer.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,14 @@ func (f *FakeImporter) Reset() {

func (_f1 *FakeImporter) Scan(ident1 *Scanner) (ident2 z.Reader) {
invocation := new(ImporterScanInvocation)
_f1.ScanCalls = append(_f1.ScanCalls, invocation)

invocation.Parameters.Ident1 = ident1

ident2 = _f1.ScanHook(ident1)

invocation.Results.Ident2 = ident2

_f1.ScanCalls = append(_f1.ScanCalls, invocation)

return
}

Expand Down
6 changes: 2 additions & 4 deletions testdata/interfacer/interfacer.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,14 @@ func (f *FakeInterfacer) Reset() {

func (_f1 *FakeInterfacer) Interface(ident1 interface{}) (ident2 interface{}) {
invocation := new(InterfacerInterfaceInvocation)
_f1.InterfaceCalls = append(_f1.InterfaceCalls, invocation)

invocation.Parameters.Ident1 = ident1

ident2 = _f1.InterfaceHook(ident1)

invocation.Results.Ident2 = ident2

_f1.InterfaceCalls = append(_f1.InterfaceCalls, invocation)

return
}

Expand Down Expand Up @@ -245,15 +244,14 @@ func (_f6 *FakeInterfacer) InterfaceResultsForCall(ident1 interface{}) (ident2 i

func (_f7 *FakeInterfacer) NamedInterface(a interface{}) (z interface{}) {
invocation := new(InterfacerNamedInterfaceInvocation)
_f7.NamedInterfaceCalls = append(_f7.NamedInterfaceCalls, invocation)

invocation.Parameters.A = a

z = _f7.NamedInterfaceHook(a)

invocation.Results.Z = z

_f7.NamedInterfaceCalls = append(_f7.NamedInterfaceCalls, invocation)

return
}

Expand Down
6 changes: 2 additions & 4 deletions testdata/mapper/mapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,12 @@ func (f *FakeMapper) Reset() {

func (_f1 *FakeMapper) MapParameter(ident1 map[string]string) {
invocation := new(MapperMapParameterInvocation)
_f1.MapParameterCalls = append(_f1.MapParameterCalls, invocation)

invocation.Parameters.Ident1 = ident1

_f1.MapParameterHook(ident1)

_f1.MapParameterCalls = append(_f1.MapParameterCalls, invocation)

return
}

Expand Down Expand Up @@ -224,13 +223,12 @@ func (_f5 *FakeMapper) AssertMapParameterCalledOnceWith(t MapperTestingT, ident1

func (_f6 *FakeMapper) MapReturn() (ident1 map[string]string) {
invocation := new(MapperMapReturnInvocation)
_f6.MapReturnCalls = append(_f6.MapReturnCalls, invocation)

ident1 = _f6.MapReturnHook()

invocation.Results.Ident1 = ident1

_f6.MapReturnCalls = append(_f6.MapReturnCalls, invocation)

return
}

Expand Down
6 changes: 2 additions & 4 deletions testdata/multireturner/multireturner.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,13 @@ func (f *FakeMultireturner) Reset() {

func (_f1 *FakeMultireturner) MultiReturn() (ident1 string, ident2 int) {
invocation := new(MultireturnerMultiReturnInvocation)
_f1.MultiReturnCalls = append(_f1.MultiReturnCalls, invocation)

ident1, ident2 = _f1.MultiReturnHook()

invocation.Results.Ident1 = ident1
invocation.Results.Ident2 = ident2

_f1.MultiReturnCalls = append(_f1.MultiReturnCalls, invocation)

return
}

Expand Down Expand Up @@ -172,6 +171,7 @@ func (f *FakeMultireturner) AssertMultiReturnCalledN(t MultireturnerTestingT, n

func (_f2 *FakeMultireturner) NamedReturn() (a int, b int, c int, d int) {
invocation := new(MultireturnerNamedReturnInvocation)
_f2.NamedReturnCalls = append(_f2.NamedReturnCalls, invocation)

a, b, c, d = _f2.NamedReturnHook()

Expand All @@ -180,8 +180,6 @@ func (_f2 *FakeMultireturner) NamedReturn() (a int, b int, c int, d int) {
invocation.Results.C = c
invocation.Results.D = d

_f2.NamedReturnCalls = append(_f2.NamedReturnCalls, invocation)

return
}

Expand Down
6 changes: 2 additions & 4 deletions testdata/namedvaluer/namedvaluer.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ func (f *FakeNamedvaluer) Reset() {

func (_f1 *FakeNamedvaluer) ManyNamed(a string, b string, f int, g int) (ret bool) {
invocation := new(NamedvaluerManyNamedInvocation)
_f1.ManyNamedCalls = append(_f1.ManyNamedCalls, invocation)

invocation.Parameters.A = a
invocation.Parameters.B = b
Expand All @@ -125,8 +126,6 @@ func (_f1 *FakeNamedvaluer) ManyNamed(a string, b string, f int, g int) (ret boo

invocation.Results.Ret = ret

_f1.ManyNamedCalls = append(_f1.ManyNamedCalls, invocation)

return
}

Expand Down Expand Up @@ -252,6 +251,7 @@ func (_f6 *FakeNamedvaluer) ManyNamedResultsForCall(a string, b string, f int, g

func (_f7 *FakeNamedvaluer) Named(a int, b string) (ret bool) {
invocation := new(NamedvaluerNamedInvocation)
_f7.NamedCalls = append(_f7.NamedCalls, invocation)

invocation.Parameters.A = a
invocation.Parameters.B = b
Expand All @@ -260,8 +260,6 @@ func (_f7 *FakeNamedvaluer) Named(a int, b string) (ret bool) {

invocation.Results.Ret = ret

_f7.NamedCalls = append(_f7.NamedCalls, invocation)

return
}

Expand Down
Loading

0 comments on commit afaee97

Please sign in to comment.