diff --git a/component/file_cache/file_cache_linux_test.go b/component/file_cache/file_cache_linux_test.go index c1122bdcc..6c016a5a4 100644 --- a/component/file_cache/file_cache_linux_test.go +++ b/component/file_cache/file_cache_linux_test.go @@ -140,8 +140,8 @@ func (suite *fileCacheLinuxTestSuite) TestChmodInCache() { // Setup path := "file34" createHandle, _ := suite.fileCache.CreateFile(internal.CreateFileOptions{Name: path, Mode: 0666}) - suite.fileCache.CloseFile(internal.CloseFileOptions{Handle: createHandle}) openHandle, _ := suite.fileCache.OpenFile(internal.OpenFileOptions{Name: path, Mode: 0666}) + suite.fileCache.CloseFile(internal.CloseFileOptions{Handle: createHandle}) // Path should be in the file cache suite.assert.FileExists(suite.cache_path + "/" + path) @@ -238,10 +238,8 @@ func (suite *fileCacheLinuxTestSuite) TestChownInCache() { // Setup path := "file37" createHandle, _ := suite.fileCache.CreateFile(internal.CreateFileOptions{Name: path, Mode: 0777}) - suite.fileCache.CloseFile(internal.CloseFileOptions{Handle: createHandle}) openHandle, _ := suite.fileCache.OpenFile(internal.OpenFileOptions{Name: path, Mode: 0777}) - err := suite.fileCache.downloadFile(openHandle) - suite.assert.NoError(err) + suite.fileCache.CloseFile(internal.CloseFileOptions{Handle: createHandle}) // Path should be in the file cache suite.assert.FileExists(suite.cache_path + "/" + path) @@ -251,7 +249,7 @@ func (suite *fileCacheLinuxTestSuite) TestChownInCache() { // Chown owner := os.Getuid() group := os.Getgid() - err = suite.fileCache.Chown(internal.ChownOptions{Name: path, Owner: owner, Group: group}) + err := suite.fileCache.Chown(internal.ChownOptions{Name: path, Owner: owner, Group: group}) suite.assert.NoError(err) // Path in fake storage and file cache should be updated info, err := os.Stat(suite.cache_path + "/" + path) diff --git a/component/file_cache/file_cache_test.go b/component/file_cache/file_cache_test.go index 87a6addd5..29563f730 100644 --- a/component/file_cache/file_cache_test.go +++ b/component/file_cache/file_cache_test.go @@ -1313,10 +1313,10 @@ func (suite *fileCacheTestSuite) TestRenameFileInCache() { dst := "destination2" createHandle, err := suite.fileCache.CreateFile(internal.CreateFileOptions{Name: src, Mode: 0666}) suite.assert.NoError(err) - err = suite.fileCache.CloseFile(internal.CloseFileOptions{Handle: createHandle}) - suite.assert.NoError(err) openHandle, err := suite.fileCache.OpenFile(internal.OpenFileOptions{Name: src, Mode: 0666}) suite.assert.NoError(err) + err = suite.fileCache.CloseFile(internal.CloseFileOptions{Handle: createHandle}) + suite.assert.NoError(err) // Path should be in the file cache suite.assert.FileExists(filepath.Join(suite.cache_path, src)) @@ -1365,8 +1365,8 @@ func (suite *fileCacheTestSuite) TestRenameFileAndCacheCleanup() { src := "source4" dst := "destination4" createHandle, _ := suite.fileCache.CreateFile(internal.CreateFileOptions{Name: src, Mode: 0666}) - suite.fileCache.CloseFile(internal.CloseFileOptions{Handle: createHandle}) openHandle, _ := suite.fileCache.OpenFile(internal.OpenFileOptions{Name: src, Mode: 0666}) + suite.fileCache.CloseFile(internal.CloseFileOptions{Handle: createHandle}) // Path should be in the file cache suite.assert.FileExists(suite.cache_path + "/" + src) @@ -1402,8 +1402,8 @@ func (suite *fileCacheTestSuite) TestRenameFileAndCacheCleanupWithNoTimeout() { src := "source5" dst := "destination5" createHandle, _ := suite.fileCache.CreateFile(internal.CreateFileOptions{Name: src, Mode: 0666}) - suite.fileCache.CloseFile(internal.CloseFileOptions{Handle: createHandle}) openHandle, _ := suite.fileCache.OpenFile(internal.OpenFileOptions{Name: src, Mode: 0666}) + suite.fileCache.CloseFile(internal.CloseFileOptions{Handle: createHandle}) // Path should be in the file cache suite.assert.FileExists(suite.cache_path + "/" + src) @@ -1457,8 +1457,8 @@ func (suite *fileCacheTestSuite) TestTruncateFileInCache() { // Setup path := "file31" createHandle, _ := suite.fileCache.CreateFile(internal.CreateFileOptions{Name: path, Mode: 0666}) - suite.fileCache.CloseFile(internal.CloseFileOptions{Handle: createHandle}) openHandle, _ := suite.fileCache.OpenFile(internal.OpenFileOptions{Name: path, Mode: 0666}) + suite.fileCache.CloseFile(internal.CloseFileOptions{Handle: createHandle}) // Path should be in the file cache suite.assert.FileExists(filepath.Join(suite.cache_path, path)) @@ -1693,8 +1693,6 @@ func (suite *fileCacheTestSuite) TestHardLimitOnSize() { smallHandle, err := suite.fileCache.OpenFile(internal.OpenFileOptions{Name: pathsmall, Flags: os.O_RDONLY, Mode: suite.fileCache.defaultPermission}) suite.assert.NoError(err) // try opening small file - err = suite.fileCache.downloadFile(smallHandle) - suite.assert.NoError(err) suite.assert.False(smallHandle.Dirty()) err = suite.fileCache.CloseFile(internal.CloseFileOptions{Handle: smallHandle}) suite.assert.NoError(err) diff --git a/component/file_cache/file_cache_windows_test.go b/component/file_cache/file_cache_windows_test.go index 3cd256e5f..c1b9cc3f2 100644 --- a/component/file_cache/file_cache_windows_test.go +++ b/component/file_cache/file_cache_windows_test.go @@ -142,25 +142,22 @@ func (suite *fileCacheWindowsTestSuite) TestChownInCache() { // Setup path := "file" createHandle, _ := suite.fileCache.CreateFile(internal.CreateFileOptions{Name: path, Mode: 0777}) - suite.fileCache.CloseFile(internal.CloseFileOptions{Handle: createHandle}) openHandle, _ := suite.fileCache.OpenFile(internal.OpenFileOptions{Name: path, Mode: 0777}) - err := suite.fileCache.downloadFile(openHandle) - suite.assert.NoError(err) + suite.fileCache.CloseFile(internal.CloseFileOptions{Handle: createHandle}) // Path should be in the file cache suite.assert.FileExists(suite.cache_path + "/" + path) // Path should be in fake storage suite.assert.FileExists(suite.fake_storage_path + "/" + path) - // Chown is not supportred on Windows, but checking that calling it does not cause an error + // Chown is not supported on Windows, but checking that calling it does not cause an error owner := os.Getuid() group := os.Getgid() - err = suite.fileCache.Chown(internal.ChownOptions{Name: path, Owner: owner, Group: group}) + err := suite.fileCache.Chown(internal.ChownOptions{Name: path, Owner: owner, Group: group}) suite.assert.NoError(err) // Checking that nothing changed with existing files suite.assert.FileExists(suite.cache_path + "/" + path) - suite.assert.FileExists(suite.fake_storage_path + "/" + path) suite.fileCache.CloseFile(internal.CloseFileOptions{Handle: openHandle})