Create 'TestVendoredBuildConstraints'

This commit is contained in:
Harald Nordgren 2018-09-18 15:44:55 +02:00
parent fbe042a544
commit 964359ea22
4 changed files with 49 additions and 0 deletions

View File

@ -197,6 +197,28 @@ func TestVendoredPackages(t *testing.T) {
}
}
func TestVendoredBuildConstraints(t *testing.T) {
m, err := New("testpackages/buildconstraints/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)
}
s := buf.String()
// assertions of things that should be mentioned
var strs = []string{
`"github.com/matryer/buildconstraints"`,
}
for _, str := range strs {
if !strings.Contains(s, str) {
t.Errorf("expected but missing: \"%s\"", str)
}
}
}
// TestDotImports tests for https://github.com/matryer/moq/issues/21.
func TestDotImports(t *testing.T) {
preDir, err := os.Getwd()

View File

@ -0,0 +1,9 @@
package user
import "github.com/matryer/buildconstraints"
// Service does something good with computers.
type Service interface {
DoSomething(buildconstraints.SomeType) error
}

View File

@ -0,0 +1,12 @@
// +build go1.7
package buildconstraints
var someVariable = "Value 1"
// SomeType is just some old type.
type SomeType struct {
// Truth indicates whether true is true or not. Computers.
Truth bool
}

View File

@ -0,0 +1,6 @@
// +build !go1.7
package buildconstraints
var someVariable = "Value 2"