Skip to content

Commit c7f4a31

Browse files
committed
Update to use a golden file test, instead of just comparing a string
1 parent a024924 commit c7f4a31

File tree

2 files changed

+81
-16
lines changed

2 files changed

+81
-16
lines changed

Diff for: pkg/moq/moq_test.go

+6-16
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,12 @@ func TestMockGolden(t *testing.T) {
412412
interfaces: []string{"Magician"},
413413
goldenFile: filepath.Join("testpackages/rangenum", "rangenum_moq.golden.go"),
414414
},
415+
{
416+
name: "TypeAlias",
417+
cfg: Config{SrcDir: "testpackages/typealias"},
418+
interfaces: []string{"Example"},
419+
goldenFile: filepath.Join("testpackages/typealias", "typealias_moq.golden.go"),
420+
},
415421
}
416422
for _, tc := range cases {
417423
t.Run(tc.name, func(t *testing.T) {
@@ -664,22 +670,6 @@ func TestImportedPackageWithSameName(t *testing.T) {
664670
}
665671
}
666672

667-
func TestImportedPackageWithTypeAlias(t *testing.T) {
668-
m, err := New(Config{SrcDir: "testpackages/typealias"})
669-
if err != nil {
670-
t.Fatalf("moq.New: %s", err)
671-
}
672-
var buf bytes.Buffer
673-
err = m.Mock(&buf, "Example")
674-
if err != nil {
675-
t.Errorf("mock error: %s", err)
676-
}
677-
s := buf.String()
678-
if !strings.Contains(s, `a typealiastwo.AliasType`) {
679-
t.Error("missing typealiastwo.AliasType")
680-
}
681-
}
682-
683673
func TestParseError(t *testing.T) {
684674
_, err := New(Config{SrcDir: "testpackages/_parseerror/service"})
685675
if err == nil {

Diff for: pkg/moq/testpackages/typealias/typealias_moq.golden.go

+75
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)