Skip to content

Commit 01b31f3

Browse files
author
Florian
committed
DataRace Fixed. ExcludePaths are set before the sync starts
1 parent 0918914 commit 01b31f3

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

pkg/devspace/sync/sync_config_test.go

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ func createTestSyncClient(testLocalPath, testRemotePath string) *SyncConfig {
3434
DestPath: testRemotePath,
3535

3636
testing: true,
37-
verbose: true,
3837
}
3938
}
4039

@@ -132,6 +131,7 @@ func TestInitialSync(t *testing.T) {
132131
defer syncClient.Stop()
133132

134133
syncClient.errorChan = make(chan error)
134+
setExcludePaths(syncClient)
135135

136136
// Start client
137137
err := syncClient.setup()
@@ -154,7 +154,7 @@ func TestInitialSync(t *testing.T) {
154154
return
155155
}
156156

157-
filesToCheck, foldersToCheck := createTestFolders(local, remote, syncClient)
157+
filesToCheck, foldersToCheck := createTestFilesAndFolders(local, remote, syncClient)
158158

159159
go syncClient.startUpstream()
160160

@@ -165,7 +165,7 @@ func TestInitialSync(t *testing.T) {
165165
return
166166
}
167167

168-
checkFilesAndFolders(t, filesToCheck, foldersToCheck, local, remote, 20*time.Second)
168+
checkFilesAndFolders(t, filesToCheck, foldersToCheck, local, remote, 10*time.Second)
169169
}
170170
func TestNormalSync(t *testing.T) {
171171
if runtime.GOOS == "windows" {
@@ -180,6 +180,7 @@ func TestNormalSync(t *testing.T) {
180180
defer syncClient.Stop()
181181

182182
syncClient.errorChan = make(chan error)
183+
setExcludePaths(syncClient)
183184

184185
// Start client
185186
err := syncClient.setup()
@@ -205,7 +206,7 @@ func TestNormalSync(t *testing.T) {
205206
go syncClient.startUpstream()
206207
go syncClient.startDownstream()
207208

208-
filesToCheck, foldersToCheck := createTestFolders(local, remote, syncClient)
209+
filesToCheck, foldersToCheck := createTestFilesAndFolders(local, remote, syncClient)
209210

210211
checkFilesAndFolders(t, filesToCheck, foldersToCheck, local, remote, 20*time.Second)
211212
}
@@ -308,7 +309,7 @@ func TestRunningSync(t *testing.T) {
308309
}
309310
}
310311

311-
func createTestFolders(local string, remote string, syncClient *SyncConfig) ([]checkedFileOrFolder, []checkedFileOrFolder) {
312+
func setExcludePaths(syncClient *SyncConfig) {
312313

313314
syncClient.ExcludePaths = []string{
314315
"ignoreFileLocal",
@@ -337,6 +338,12 @@ func createTestFolders(local string, remote string, syncClient *SyncConfig) ([]c
337338
"testFolder/noUploadFileRemote",
338339
}
339340

341+
syncClient.initIgnoreParsers()
342+
343+
}
344+
345+
func createTestFilesAndFolders(local string, remote string, syncClient *SyncConfig) ([]checkedFileOrFolder, []checkedFileOrFolder) {
346+
340347
//Write local files
341348
ioutil.WriteFile(path.Join(local, "testFile1"), []byte(fileContents), 0666)
342349
ioutil.WriteFile(path.Join(local, "testFile2"), []byte(fileContents), 0666)
@@ -371,9 +378,9 @@ func createTestFolders(local string, remote string, syncClient *SyncConfig) ([]c
371378

372379
ioutil.WriteFile(path.Join(remote, "testFolder", "testFile3"), []byte(fileContents), 0666)
373380
ioutil.WriteFile(path.Join(remote, "testFolder", "testFile4"), []byte(fileContents), 0666)
374-
ioutil.WriteFile(path.Join(remote, "testFolder", "ignoreFileRemote"), []byte(fileContents), 0666)
375-
ioutil.WriteFile(path.Join(remote, "testFolder", "noDownloadFileRemote"), []byte(fileContents), 0666)
376-
ioutil.WriteFile(path.Join(remote, "testFolder", "noUploadFileRemote"), []byte(fileContents), 0666)
381+
ioutil.WriteFile(path.Join(remote, "ignoreFileRemote"), []byte(fileContents), 0666)
382+
ioutil.WriteFile(path.Join(remote, "noDownloadFileRemote"), []byte(fileContents), 0666)
383+
ioutil.WriteFile(path.Join(remote, "noUploadFileRemote"), []byte(fileContents), 0666)
377384

378385
filesToCheck := []checkedFileOrFolder{
379386
checkedFileOrFolder{

0 commit comments

Comments
 (0)