added vendor example
This commit is contained in:
parent
be1d7ca86c
commit
df49857c18
2
main.go
2
main.go
@ -9,7 +9,7 @@ import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"github.com/matryer/moq/package/moq"
|
||||
"github.com/matryer/moq/pkg/moq"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -2,6 +2,7 @@ package moq
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"log"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
@ -153,7 +154,7 @@ func TestImports(t *testing.T) {
|
||||
s := buf.String()
|
||||
var strs = []string{
|
||||
` "sync"`,
|
||||
` "github.com/matryer/moq/package/moq/testdata/imports/one"`,
|
||||
` "github.com/matryer/moq/pkg/moq/testdata/imports/one"`,
|
||||
}
|
||||
for _, str := range strs {
|
||||
if !strings.Contains(s, str) {
|
||||
@ -171,3 +172,16 @@ func TestTemplateFuncs(t *testing.T) {
|
||||
t.Errorf("exported didn't work: %s", fn("var"))
|
||||
}
|
||||
}
|
||||
|
||||
func TestVendoredPackages(t *testing.T) {
|
||||
m, err := New("testdata/vendoring/user", "")
|
||||
if err != nil {
|
||||
t.Fatalf("moq.New: %s", err)
|
||||
}
|
||||
var buf bytes.Buffer
|
||||
err = m.Mock(&buf, "Service")
|
||||
if err != nil {
|
||||
t.Errorf("mock error: %s", err)
|
||||
}
|
||||
log.Println(buf.String())
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
package two
|
||||
|
||||
import (
|
||||
"github.com/matryer/moq/package/moq/testdata/imports/one"
|
||||
"github.com/matryer/moq/pkg/moq/testdata/imports/one"
|
||||
)
|
||||
|
||||
// DoSomething does something.
|
8
pkg/moq/testdata/vendoring/user/user.go
vendored
Normal file
8
pkg/moq/testdata/vendoring/user/user.go
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
package user
|
||||
|
||||
import "github.com/matryer/somerepo"
|
||||
|
||||
// Service does something good with computers.
|
||||
type Service interface {
|
||||
DoSomething(somerepo.SomeType) error
|
||||
}
|
9
pkg/moq/testdata/vendoring/user/vendor/github.com/matryer/somerepo/code.go
generated
vendored
Normal file
9
pkg/moq/testdata/vendoring/user/vendor/github.com/matryer/somerepo/code.go
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
// Package somerepo is a vendored package to test how moq deals with
|
||||
// packages in the vendor package.
|
||||
package somerepo
|
||||
|
||||
// SomeType is just some old type.
|
||||
type SomeType struct {
|
||||
// Truth indicates whether true is true or not. Computers.
|
||||
Truth bool
|
||||
}
|
Loading…
Reference in New Issue
Block a user