Merge pull request #73 from HaraldNordgren/TestVendoredBuildConstraints

Create 'TestVendoredBuildConstraints'
This commit is contained in:
Mat Ryer 2019-01-21 17:46:39 +00:00 committed by GitHub
commit 39f6db0ed3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 49 additions and 0 deletions

View File

@ -259,6 +259,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"