Merge pull request #73 from HaraldNordgren/TestVendoredBuildConstraints
Create 'TestVendoredBuildConstraints'
This commit is contained in:
commit
39f6db0ed3
@ -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.
|
// TestDotImports tests for https://github.com/matryer/moq/issues/21.
|
||||||
func TestDotImports(t *testing.T) {
|
func TestDotImports(t *testing.T) {
|
||||||
preDir, err := os.Getwd()
|
preDir, err := os.Getwd()
|
||||||
|
9
pkg/moq/testpackages/buildconstraints/user/user.go
Normal file
9
pkg/moq/testpackages/buildconstraints/user/user.go
Normal 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
|
||||||
|
}
|
||||||
|
|
12
pkg/moq/testpackages/buildconstraints/vendor/github.com/matryer/buildconstraints/go17.go
generated
vendored
Normal file
12
pkg/moq/testpackages/buildconstraints/vendor/github.com/matryer/buildconstraints/go17.go
generated
vendored
Normal 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
|
||||||
|
}
|
||||||
|
|
6
pkg/moq/testpackages/buildconstraints/vendor/github.com/matryer/buildconstraints/pre_go17.go
generated
vendored
Normal file
6
pkg/moq/testpackages/buildconstraints/vendor/github.com/matryer/buildconstraints/pre_go17.go
generated
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
// +build !go1.7
|
||||||
|
|
||||||
|
package buildconstraints
|
||||||
|
|
||||||
|
var someVariable = "Value 2"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user