(t *testing.T)
| 198 | } |
| 199 | |
| 200 | func TestInternalUploadTempFileOperations(t *testing.T) { |
| 201 | id := "tiutfo" |
| 202 | rootFs, boltDb := runInstance.newCacheFs(t, remoteName, id, true, true, |
| 203 | map[string]string{"tmp_upload_path": path.Join(runInstance.tmpUploadDir, id), "tmp_wait_time": "1h"}) |
| 204 | |
| 205 | boltDb.PurgeTempUploads() |
| 206 | |
| 207 | // create some rand test data |
| 208 | runInstance.mkdir(t, rootFs, "test") |
| 209 | runInstance.writeRemoteString(t, rootFs, "test/one", "one content") |
| 210 | |
| 211 | // check if it can be read |
| 212 | data1, err := runInstance.readDataFromRemote(t, rootFs, "test/one", 0, int64(len([]byte("one content"))), false) |
| 213 | require.NoError(t, err) |
| 214 | require.Equal(t, []byte("one content"), data1) |
| 215 | // validate that it exists in temp fs |
| 216 | _, err = os.Stat(path.Join(runInstance.tmpUploadDir, id, runInstance.encryptRemoteIfNeeded(t, "test/one"))) |
| 217 | require.NoError(t, err) |
| 218 | |
| 219 | // test DirMove - allowed |
| 220 | err = runInstance.dirMove(t, rootFs, "test", "second") |
| 221 | if err != errNotSupported { |
| 222 | require.NoError(t, err) |
| 223 | _, err = rootFs.NewObject(context.Background(), "test/one") |
| 224 | require.Error(t, err) |
| 225 | _, err = rootFs.NewObject(context.Background(), "second/one") |
| 226 | require.NoError(t, err) |
| 227 | // validate that it exists in temp fs |
| 228 | _, err = os.Stat(path.Join(runInstance.tmpUploadDir, id, runInstance.encryptRemoteIfNeeded(t, "test/one"))) |
| 229 | require.Error(t, err) |
| 230 | _, err = os.Stat(path.Join(runInstance.tmpUploadDir, id, runInstance.encryptRemoteIfNeeded(t, "second/one"))) |
| 231 | require.NoError(t, err) |
| 232 | _, err = boltDb.SearchPendingUpload(runInstance.encryptRemoteIfNeeded(t, path.Join(id, "test/one"))) |
| 233 | require.Error(t, err) |
| 234 | var started bool |
| 235 | started, err = boltDb.SearchPendingUpload(runInstance.encryptRemoteIfNeeded(t, path.Join(id, "second/one"))) |
| 236 | require.NoError(t, err) |
| 237 | require.False(t, started) |
| 238 | runInstance.mkdir(t, rootFs, "test") |
| 239 | runInstance.writeRemoteString(t, rootFs, "test/one", "one content") |
| 240 | } |
| 241 | |
| 242 | // test Rmdir - allowed |
| 243 | err = runInstance.rm(t, rootFs, "test") |
| 244 | require.Error(t, err) |
| 245 | require.Contains(t, err.Error(), "directory not empty") |
| 246 | _, err = rootFs.NewObject(context.Background(), "test/one") |
| 247 | require.NoError(t, err) |
| 248 | // validate that it exists in temp fs |
| 249 | _, err = os.Stat(path.Join(runInstance.tmpUploadDir, id, runInstance.encryptRemoteIfNeeded(t, "test/one"))) |
| 250 | require.NoError(t, err) |
| 251 | started, err := boltDb.SearchPendingUpload(runInstance.encryptRemoteIfNeeded(t, path.Join(id, "test/one"))) |
| 252 | require.False(t, started) |
| 253 | require.NoError(t, err) |
| 254 | |
| 255 | // test Move/Rename -- allowed |
| 256 | err = runInstance.move(t, rootFs, path.Join("test", "one"), path.Join("test", "second")) |
| 257 | if err != errNotSupported { |
nothing calls this directly
no test coverage detected
searching dependent graphs…