wire: use return in tests instead of panic (google/go-cloud#169)

Fixes google/go-cloud#105
This commit is contained in:
Ross Light
2018-07-06 11:18:07 -07:00
parent 5e442802c0
commit 9537acefc2
31 changed files with 58 additions and 31 deletions

View File

@@ -21,5 +21,6 @@ import (
) )
func injectFooBar() FooBar { func injectFooBar() FooBar {
panic(wire.Build(Set)) wire.Build(Set)
return 0
} }

View File

@@ -21,5 +21,6 @@ import (
) )
func injectBar() (*Bar, func()) { func injectBar() (*Bar, func()) {
panic(wire.Build(provideFoo, provideBar)) wire.Build(provideFoo, provideBar)
return nil, nil
} }

View File

@@ -35,5 +35,6 @@ func provideMessage() string {
} }
func injectedMessage() string { func injectedMessage() string {
panic(wire.Build(provideMessage)) wire.Build(provideMessage)
return ""
} }

View File

@@ -21,5 +21,6 @@ import (
) )
func injectedBaz() Baz { func injectedBaz() Baz {
panic(wire.Build(provideFoo, provideBar, provideBaz)) wire.Build(provideFoo, provideBar, provideBaz)
return 0
} }

View File

@@ -21,5 +21,6 @@ import (
) )
func injectedMessage() string { func injectedMessage() string {
panic(wire.Build(myFakeSet)) wire.Build(myFakeSet)
return ""
} }

View File

@@ -22,5 +22,6 @@ import (
) )
func injectedMessage() string { func injectedMessage() string {
panic(wire.Build(bar.Value)) wire.Build(bar.Value)
return ""
} }

View File

@@ -24,5 +24,6 @@ import (
) )
func injectedFile() *os.File { func injectedFile() *os.File {
panic(wire.Build(bar.Value)) wire.Build(bar.Value)
return nil
} }

View File

@@ -17,10 +17,11 @@
package main package main
import ( import (
"github.com/google/go-cloud/wire"
"foo" "foo"
"github.com/google/go-cloud/wire"
) )
func injectFooer() foo.Fooer { func injectFooer() foo.Fooer {
panic(wire.Build(Set)) wire.Build(Set)
return nil
} }

View File

@@ -21,5 +21,6 @@ import (
) )
func injectFooBar(foo Foo) FooBar { func injectFooBar(foo Foo) FooBar {
panic(wire.Build(Set)) wire.Build(Set)
return 0
} }

View File

@@ -21,5 +21,6 @@ import (
) )
func injectBar(foo Foo) Bar { func injectBar(foo Foo) Bar {
panic(wire.Build(Set)) wire.Build(Set)
return 0
} }

View File

@@ -21,6 +21,5 @@ import (
) )
func injectedMessage() string { func injectedMessage() string {
wire.Build(provideMessage) panic(wire.Build(provideMessage))
return ""
} }

View File

@@ -21,5 +21,6 @@ import (
) )
func injectFooer() Fooer { func injectFooer() Fooer {
panic(wire.Build(Set)) wire.Build(Set)
return nil
} }

View File

@@ -21,8 +21,10 @@ import (
) )
func injectFooBar() FooBar { func injectFooBar() FooBar {
panic(wire.Build( wire.Build(
provideBar, provideBar,
provideFooBar, provideFooBar,
wire.Bind((*Fooer)(nil), (*Bar)(nil)))) wire.Bind((*Fooer)(nil), (*Bar)(nil)),
)
return FooBar{}
} }

View File

@@ -21,5 +21,6 @@ import (
) )
func injectedMessage() string { func injectedMessage() string {
panic(wire.Build(provideMessage)) wire.Build(provideMessage)
return ""
} }

View File

@@ -21,5 +21,6 @@ import (
) )
func injectedMessage() string { func injectedMessage() string {
panic(wire.Build(wire.Value("Hello, World!"))) wire.Build(wire.Value("Hello, World!"))
return ""
} }

View File

@@ -21,5 +21,6 @@ import (
) )
func injectFooer() Fooer { func injectFooer() Fooer {
panic(wire.Build(provideBar)) wire.Build(provideBar)
return nil
} }

View File

@@ -26,5 +26,6 @@ import (
// parameter names on the inject stub. // parameter names on the inject stub.
func inject(stdcontext.Context, struct{}) (context, error) { func inject(stdcontext.Context, struct{}) (context, error) {
panic(wire.Build(provide)) wire.Build(provide)
return context{}, nil
} }

View File

@@ -21,5 +21,6 @@ import (
) )
func injectBaz() (Baz, func(), error) { func injectBaz() (Baz, func(), error) {
panic(wire.Build(provideFoo, provideBar, provideBaz)) wire.Build(provideFoo, provideBar, provideBaz)
return 0, nil, nil
} }

View File

@@ -21,5 +21,6 @@ import (
) )
func injectFooBar() FooBar { func injectFooBar() FooBar {
panic(wire.Build(Set)) wire.Build(Set)
return 0
} }

View File

@@ -21,5 +21,6 @@ import (
) )
func injectFoo() (Foo, error) { func injectFoo() (Foo, error) {
panic(wire.Build(Set)) wire.Build(Set)
return 0, nil
} }

View File

@@ -21,5 +21,6 @@ import (
) )
func injectFooBar() FooBar { func injectFooBar() FooBar {
panic(wire.Build(Set)) wire.Build(Set)
return FooBar{}
} }

View File

@@ -21,5 +21,6 @@ import (
) )
func injectFooBar() *FooBar { func injectFooBar() *FooBar {
panic(wire.Build(Set)) wire.Build(Set)
return nil
} }

View File

@@ -21,5 +21,6 @@ import (
) )
func injectFooBar() FooBar { func injectFooBar() FooBar {
panic(wire.Build(Set)) wire.Build(Set)
return 0
} }

View File

@@ -22,5 +22,6 @@ import (
) )
func injectedMessage() string { func injectedMessage() string {
panic(wire.Build(bar.Value)) wire.Build(bar.Value)
return ""
} }

View File

@@ -21,5 +21,6 @@ import (
) )
func injectFooBar() FooBar { func injectFooBar() FooBar {
panic(wire.Build(Set)) wire.Build(Set)
return 0
} }

View File

@@ -21,5 +21,6 @@ import (
) )
func injectedMessage() Foo { func injectedMessage() Foo {
panic(wire.Build(wire.Value(Foo("Hello, World!")))) wire.Build(wire.Value(Foo("Hello, World!")))
return ""
} }

View File

@@ -21,5 +21,6 @@ import (
) )
func injectedMessage() string { func injectedMessage() string {
panic(wire.Build(wire.Value(msg))) wire.Build(wire.Value(msg))
return ""
} }

View File

@@ -22,5 +22,6 @@ import (
) )
func injectedMessage() string { func injectedMessage() string {
panic(wire.Build(bar.ProvideMessage)) wire.Build(bar.ProvideMessage)
return ""
} }