mirror of
				https://github.com/k3s-io/kubernetes.git
				synced 2025-11-03 23:40:03 +00:00 
			
		
		
		
	remove duplicated cleaning up func
This commit is contained in:
		@@ -321,10 +321,6 @@ func watchFileChanged(watchDir bool, symlink bool, t *testing.T) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			if watchDir {
 | 
								if watchDir {
 | 
				
			||||||
				NewSourceFile(dirName, hostname, 100*time.Millisecond, ch)
 | 
									NewSourceFile(dirName, hostname, 100*time.Millisecond, ch)
 | 
				
			||||||
				defer func() {
 | 
					 | 
				
			||||||
					// Remove the file
 | 
					 | 
				
			||||||
					deleteFile(dirName, fileName, ch, t)
 | 
					 | 
				
			||||||
				}()
 | 
					 | 
				
			||||||
			} else {
 | 
								} else {
 | 
				
			||||||
				NewSourceFile(file, hostname, 100*time.Millisecond, ch)
 | 
									NewSourceFile(file, hostname, 100*time.Millisecond, ch)
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
@@ -363,22 +359,6 @@ func watchFileChanged(watchDir bool, symlink bool, t *testing.T) {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func deleteFile(dir, file string, ch chan interface{}, t *testing.T) {
 | 
					 | 
				
			||||||
	path := filepath.Join(dir, file)
 | 
					 | 
				
			||||||
	if _, err := os.Stat(path); err != nil {
 | 
					 | 
				
			||||||
		// The file might absent if it's renamed, deleted..
 | 
					 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	go func() {
 | 
					 | 
				
			||||||
		err := os.Remove(path)
 | 
					 | 
				
			||||||
		if err != nil {
 | 
					 | 
				
			||||||
			t.Errorf("unable to remove test file %s: %s", path, err)
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}()
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	expectEmptyUpdate(t, ch)
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func expectUpdate(t *testing.T, ch chan interface{}, testCase *testCase) {
 | 
					func expectUpdate(t *testing.T, ch chan interface{}, testCase *testCase) {
 | 
				
			||||||
	timer := time.After(5 * time.Second)
 | 
						timer := time.After(5 * time.Second)
 | 
				
			||||||
	for {
 | 
						for {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user