Skip to content

Commit 1cd23af

Browse files
committed
Cleanup returns a pointer to fixture
1 parent 79a68c8 commit 1cd23af

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

internal/renderer/templates/fixture.tmpl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@
7272
return c
7373
}
7474

75-
func (f *{{ .Struct.Type.TypeName }}Fixture) Cleanup(tb testing.TB) {
75+
// Cleanup calls testing.TB.Cleanup() function with providing a callback inside it.
76+
// This callback will delete a record from the table by primary key when test will be finished.
77+
func (f *{{ .Struct.Type.TypeName }}Fixture) Cleanup(tb testing.TB) *{{ $.Struct.Type.TypeName }}Fixture {
7678
tb.Cleanup(
7779
func() {
7880
{{- $addPrimary := false -}}
@@ -91,6 +93,8 @@
9193
tb.Fatalf("failed to cleanup {{ .Struct.Type.TypeName }}: %v", err)
9294
}
9395
})
96+
97+
return f
9498
}
9599

96100
{{ if .Struct.HasPrimaryKey}}

0 commit comments

Comments
 (0)