added test to prove variadic args aren't working
This commit is contained in:
parent
b050476316
commit
92c01adec9
@ -2,7 +2,7 @@ package example
|
|||||||
|
|
||||||
import "context"
|
import "context"
|
||||||
|
|
||||||
//go:generate moq PersonStore -out mockpersonstore_test.go
|
//go:generate moq -out mockpersonstore_test.go PersonStore
|
||||||
|
|
||||||
type Person struct {
|
type Person struct {
|
||||||
ID string
|
ID string
|
||||||
|
@ -7,7 +7,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestMoq(t *testing.T) {
|
func TestMoq(t *testing.T) {
|
||||||
m, err := New("../../example", "")
|
m, err := New("testdata/example", "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("moq.New: %s", err)
|
t.Errorf("moq.New: %s", err)
|
||||||
}
|
}
|
||||||
@ -34,7 +34,7 @@ func TestMoq(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestMoqExplicitPackage(t *testing.T) {
|
func TestMoqExplicitPackage(t *testing.T) {
|
||||||
m, err := New("../../example", "different")
|
m, err := New("testdata/example", "different")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("moq.New: %s", err)
|
t.Errorf("moq.New: %s", err)
|
||||||
}
|
}
|
||||||
@ -59,3 +59,30 @@ func TestMoqExplicitPackage(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TestVeradicArguments tests to ensure variadic work as
|
||||||
|
// expected.
|
||||||
|
// see https://github.com/matryer/moq/issues/5
|
||||||
|
func TestVariadicArguments(t *testing.T) {
|
||||||
|
m, err := New("testdata/variadic", "")
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("moq.New: %s", err)
|
||||||
|
}
|
||||||
|
var buf bytes.Buffer
|
||||||
|
err = m.Mock(&buf, "Greeter")
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("m.Mock: %s", err)
|
||||||
|
}
|
||||||
|
s := buf.String()
|
||||||
|
// assertions of things that should be mentioned
|
||||||
|
var strs = []string{
|
||||||
|
"package variadic",
|
||||||
|
"type GreeterMock struct",
|
||||||
|
"GreetFunc func(ctx context.Context, names ...string) string",
|
||||||
|
}
|
||||||
|
for _, str := range strs {
|
||||||
|
if !strings.Contains(s, str) {
|
||||||
|
t.Errorf("expected but missing: \"%s\"", str)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
15
package/moq/testdata/example/example.go
vendored
Normal file
15
package/moq/testdata/example/example.go
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
package example
|
||||||
|
|
||||||
|
import "context"
|
||||||
|
|
||||||
|
type Person struct {
|
||||||
|
ID string
|
||||||
|
Name string
|
||||||
|
Company string
|
||||||
|
Website string
|
||||||
|
}
|
||||||
|
|
||||||
|
type PersonStore interface {
|
||||||
|
Get(ctx context.Context, id string) (*Person, error)
|
||||||
|
Create(ctx context.Context, person *Person, confirm bool) error
|
||||||
|
}
|
8
package/moq/testdata/variadic/greeter.go
vendored
Normal file
8
package/moq/testdata/variadic/greeter.go
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
package variadic
|
||||||
|
|
||||||
|
import "context"
|
||||||
|
|
||||||
|
// Greeter greets people.
|
||||||
|
type Greeter interface {
|
||||||
|
Greet(ctx context.Context, names ...string) string
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user