concourse / concourse

Use t.Setenv and friends instead of os.Setenv for test file(s) GO-W1032
Bug risk
Major
4 months agoa year old
os.Setenv() can be replaced by 'testing.Setenv()' in anonymous function
 86			Context("when FLY_HOME is unset and HOME is set", func() {
 87				BeforeEach(func() {
 88					os.Setenv("FLY_HOME", "")
 89					os.Setenv("HOME", tmpDir) 90				})
 91				It("loads from the path set in HOME", func() {
 92					targets, err := rc.LoadTargets()
os.Setenv() can be replaced by 'testing.Setenv()' in anonymous function
 85
 86			Context("when FLY_HOME is unset and HOME is set", func() {
 87				BeforeEach(func() {
 88					os.Setenv("FLY_HOME", "") 89					os.Setenv("HOME", tmpDir)
 90				})
 91				It("loads from the path set in HOME", func() {
os.Setenv() can be replaced by 'testing.Setenv()' in anonymous function
 74			Context("when FLY_HOME is set", func() {
 75				BeforeEach(func() {
 76					os.Setenv("FLY_HOME", tmpDir)
 77					os.Setenv("HOME", "/an/invalid/path") 78				})
 79				It("loads from the path set in FLY_HOME in preference to HOME", func() {
 80					targets, err := rc.LoadTargets()
os.Setenv() can be replaced by 'testing.Setenv()' in anonymous function
 73
 74			Context("when FLY_HOME is set", func() {
 75				BeforeEach(func() {
 76					os.Setenv("FLY_HOME", tmpDir) 77					os.Setenv("HOME", "/an/invalid/path")
 78				})
 79				It("loads from the path set in FLY_HOME in preference to HOME", func() {
os.Setenv() can be replaced by 'testing.Setenv()' in anonymous function
 20		tmpDir, err = os.MkdirTemp("", "fly-test")
 21		Expect(err).ToNot(HaveOccurred())
 22
 23		os.Setenv("HOME", tmpDir) 24
 25		flyrc = filepath.Join(userHomeDir(), ".flyrc")
 26	})