minor improvements
This commit is contained in:
parent
3dc5361304
commit
5d872a540b
2
main.go
2
main.go
@ -13,7 +13,7 @@ func main() {
|
||||
var err error
|
||||
defer func() {
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
flag.Usage()
|
||||
os.Exit(1)
|
||||
}
|
||||
|
@ -80,7 +80,6 @@ func (m *Mocker) Mock(w io.Writer, name ...string) error {
|
||||
iface := tpkg.Scope().Lookup(n)
|
||||
if iface == nil {
|
||||
return fmt.Errorf("cannot find interface %s", n)
|
||||
continue
|
||||
}
|
||||
if !types.IsInterface(iface.Type()) {
|
||||
return fmt.Errorf("%s (%s) not an interface", n, iface.Type().String())
|
||||
@ -190,8 +189,7 @@ func (p param) TypeString() string {
|
||||
return p.Type
|
||||
}
|
||||
|
||||
var moqTemplate = `
|
||||
package {{.PackageName}}
|
||||
var moqTemplate = `package {{.PackageName}}
|
||||
|
||||
// AUTOGENERATED BY MOQ
|
||||
// github.com/matryer/moq
|
||||
@ -224,6 +222,5 @@ func (mock *{{$obj.InterfaceName}}Mock) {{.Name}}({{.Arglist}}) {{.ReturnArglist
|
||||
}
|
||||
return mock.{{.Name}}Func({{.ArgCallList}})
|
||||
}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
`
|
||||
{{ end -}}
|
||||
{{ end -}}`
|
||||
|
@ -2,13 +2,11 @@ package moq
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"log"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestMoq(t *testing.T) {
|
||||
|
||||
m, err := New("../../example", "")
|
||||
if err != nil {
|
||||
t.Errorf("moq.New: %s", err)
|
||||
@ -19,9 +17,6 @@ func TestMoq(t *testing.T) {
|
||||
t.Errorf("m.Mock: %s", err)
|
||||
}
|
||||
s := buf.String()
|
||||
|
||||
log.Println(s)
|
||||
|
||||
// assertions of things that should be mentioned
|
||||
var strs = []string{
|
||||
"package example",
|
||||
@ -36,11 +31,9 @@ func TestMoq(t *testing.T) {
|
||||
t.Errorf("expected but missing: \"%s\"", str)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestMoqExplicitPackage(t *testing.T) {
|
||||
|
||||
m, err := New("../../example", "different")
|
||||
if err != nil {
|
||||
t.Errorf("moq.New: %s", err)
|
||||
@ -51,9 +44,6 @@ func TestMoqExplicitPackage(t *testing.T) {
|
||||
t.Errorf("m.Mock: %s", err)
|
||||
}
|
||||
s := buf.String()
|
||||
|
||||
log.Println(s)
|
||||
|
||||
// assertions of things that should be mentioned
|
||||
var strs = []string{
|
||||
"package different",
|
||||
@ -68,5 +58,4 @@ func TestMoqExplicitPackage(t *testing.T) {
|
||||
t.Errorf("expected but missing: \"%s\"", str)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user