prometheus/discovery/file
Renato Costa d521933053
Fix incorrect use of loop variable in parallel test (#11205)
This fixes an occurrence of a loop variable being captured in a
parallel test (`TestInitialUpdate`). Prior to this commit, only the
last test case declared in that test would actually execute. To work
around this problem, we create a copy of the range variable before the
paralllel test, as suggested in the documentation for the `testing`
package:

https://pkg.go.dev/testing#hdr-Subtests_and_Sub_benchmarks

The test immediately after the one fixed here (`TestInvalidFile`)
followed the same pattern but correctly created a copy of the loop
variable, illustrating how easy it is to forget to do this in
practice.

Issue was automatically found using the `loopvarcapture` linter.

Signed-off-by: Renato Costa <renato@cockroachlabs.com>

Signed-off-by: Renato Costa <renato@cockroachlabs.com>
2022-08-25 12:23:29 +02:00
..
fixtures fixes yamllint errors 2021-06-12 12:47:47 +02:00
file.go refactor (discovery): move from github.com/pkg/errors to 'errors' and 'fmt' (#10807) 2022-06-03 13:47:14 +02:00
file_test.go Fix incorrect use of loop variable in parallel test (#11205) 2022-08-25 12:23:29 +02:00