Skip to content

Commit 4fe3c28

Browse files
🌱 fix (ci): fix lint issue: shadow: declaration of pluginCfg shadows declaration (#4725)
fix (ci): fix lint issue: shadow: declaration of pluginCfg shadows declaration Fix plugin config test by resetting struct to avoid value reuse Avoids test contamination caused by shared PluginConfig variable by explicitly resetting it before decoding in each test case. Also resolves shadowing linter errors reported by golangci-lint.
1 parent 23b74ea commit 4fe3c28

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

‎pkg/config/v3/config_test.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -405,22 +405,20 @@ var _ = Describe("Cfg", func() {
405405
})
406406

407407
It("DecodePluginConfig should fail for no plugin config object", func() {
408-
var pluginCfg PluginConfig
409408
err := c0.DecodePluginConfig(key, &pluginCfg)
410409
Expect(err).To(HaveOccurred())
411410
Expect(errors.As(err, &config.PluginKeyNotFoundError{})).To(BeTrue())
412411
})
413412

414413
It("DecodePluginConfig should fail to retrieve data from a non-existent plugin", func() {
415-
var pluginCfg PluginConfig
416414
err := c1.DecodePluginConfig("plugin-y", &pluginCfg)
417415
Expect(err).To(HaveOccurred())
418416
Expect(errors.As(err, &config.PluginKeyNotFoundError{})).To(BeTrue())
419417
})
420418

421419
DescribeTable("DecodePluginConfig should retrieve the plugin data correctly",
422420
func(getCfg func() Cfg, expected func() PluginConfig) {
423-
var pluginCfg PluginConfig
421+
pluginCfg = PluginConfig{} // reset to not reuse values
424422
Expect(getCfg().DecodePluginConfig(key, &pluginCfg)).To(Succeed())
425423
Expect(pluginCfg).To(Equal(expected()))
426424
},

0 commit comments

Comments
 (0)