Skip to content

Commit

Permalink
RHOAIENG-15772: tests(odh-nbc): fix unintended shadowing of cfg var…
Browse files Browse the repository at this point in the history
…iable (#462)

This is a nasty Go gotcha, and we aren't the first to have trouble with it
https://temporal.io/blog/go-shadowing-bad-choices#the-bug
  • Loading branch information
jiridanek authored Nov 19, 2024
1 parent b5741e1 commit 658c81d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion components/notebook-controller/controllers/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ var _ = BeforeSuite(func() {
ErrorIfCRDPathMissing: true,
}

cfg, err := testEnv.Start()
var err error
cfg, err = testEnv.Start()
Expect(err).NotTo(HaveOccurred())
Expect(cfg).NotTo(BeNil())

Expand Down
3 changes: 2 additions & 1 deletion components/odh-notebook-controller/controllers/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ var _ = BeforeSuite(func() {
},
}

cfg, err := envTest.Start()
var err error
cfg, err = envTest.Start()
Expect(err).NotTo(HaveOccurred())
Expect(cfg).NotTo(BeNil())

Expand Down

0 comments on commit 658c81d

Please sign in to comment.