Skip to content

Commit 9765ec6

Browse files
committed
🌱 (chore): fix improper usage of errors.As in scaffold tests
This fixes a misuse of `errors.As` where a non-pointer was passed as the second argument. Go requires the second argument to be a pointer to an interface or a type implementing the `error` interface. The test helper now correctly uses `&errType` to ensure proper error assertion and avoid false negatives or runtime issues.
1 parent 6acdbd2 commit 9765ec6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pkg/machinery/scaffold_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ var _ = Describe("Scaffold", func() {
171171
func(errType interface{}, files ...Builder) {
172172
err := s.Execute(files...)
173173
Expect(err).To(HaveOccurred())
174-
Expect(errors.As(err, errType)).To(BeTrue())
174+
Expect(errors.As(err, &errType)).To(BeTrue())
175175
},
176176
Entry("should fail if unable to validate a file builder",
177177
&ValidateError{},
@@ -413,7 +413,7 @@ func init() {
413413

414414
err := s.Execute(files...)
415415
Expect(err).To(HaveOccurred())
416-
Expect(errors.As(err, errType)).To(BeTrue())
416+
Expect(errors.As(err, &errType)).To(BeTrue())
417417
},
418418
Entry("should fail if inserting into a model that fails when a file exists and it does exist",
419419
&FileAlreadyExistsError{},

0 commit comments

Comments
 (0)