Skip to content

Commit 2cdc0ac

Browse files
committed
Reset target paths list on each initialization of the configuration
Although not a problem for normal usage, the previous behavior of appending target paths on each call to configuration.Initialize() interfered with the ability to use this function in multiple tests.
1 parent 42cac64 commit 2cdc0ac

File tree

2 files changed

+1
-3
lines changed

2 files changed

+1
-3
lines changed

configuration/configuration.go

+1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ func Initialize(flags *pflag.FlagSet, projectPaths []string) error {
8383

8484
versionMode, _ = flags.GetBool("version")
8585

86+
targetPaths = nil
8687
if len(projectPaths) == 0 {
8788
// Default to using current working directory.
8889
workingDirectoryPath, err := os.Getwd()

configuration/configuration_test.go

-3
Original file line numberDiff line numberDiff line change
@@ -184,17 +184,14 @@ func TestInitializeVersion(t *testing.T) {
184184
}
185185

186186
func TestInitializeProjectPath(t *testing.T) {
187-
targetPaths = nil
188187
assert.Nil(t, Initialize(test.ConfigurationFlags(), []string{}))
189188
workingDirectoryPath, err := os.Getwd()
190189
require.Nil(t, err)
191190
assert.Equal(t, paths.NewPathList(workingDirectoryPath), TargetPaths(), "Default PROJECT_PATH to current working directory")
192191

193-
targetPaths = nil
194192
assert.Nil(t, Initialize(test.ConfigurationFlags(), projectPaths))
195193
assert.Equal(t, paths.NewPathList(projectPaths[0]), TargetPaths())
196194

197-
targetPaths = nil
198195
assert.Error(t, Initialize(test.ConfigurationFlags(), []string{"/nonexistent"}))
199196
}
200197

0 commit comments

Comments
 (0)