Skip to content

Commit

Permalink
check modified time sent by upload jobs in automated tests
Browse files Browse the repository at this point in the history
Signed-off-by: Matthieu Gallien <[email protected]>
  • Loading branch information
mgallien committed Jan 11, 2022
1 parent 9d7568a commit c88f57b
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions test/syncenginetestutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,8 +450,10 @@ QVector<FileInfo *> FakePutMultiFileReply::performMultiPart(FileInfo &remoteRoot
auto headerParts = oneHeader.split(QStringLiteral(": "));
allHeaders[headerParts.at(0)] = headerParts.at(1);
}
auto fileName = allHeaders[QStringLiteral("X-File-Path")];
const auto fileName = allHeaders[QStringLiteral("X-File-Path")];
const auto modtime = allHeaders[QByteArrayLiteral("X-File-Mtime")].toLongLong();
Q_ASSERT(!fileName.isEmpty());
Q_ASSERT(modtime > 0);
FileInfo *fileInfo = remoteRootFileInfo.find(fileName);
if (fileInfo) {
fileInfo->size = onePartBody.size();
Expand Down Expand Up @@ -480,13 +482,7 @@ void FakePutMultiFileReply::respond()
for(auto fileInfo : qAsConst(_allFileInfo)) {
QJsonObject fileInfoReply;
fileInfoReply.insert("error", QStringLiteral("false"));
fileInfoReply.insert("OC-OperationStatus", fileInfo->operationStatus);
fileInfoReply.insert("X-File-Path", fileInfo->path());
fileInfoReply.insert("OC-ETag", QLatin1String{fileInfo->etag});
fileInfoReply.insert("ETag", QLatin1String{fileInfo->etag});
fileInfoReply.insert("etag", QLatin1String{fileInfo->etag});
fileInfoReply.insert("OC-FileID", QLatin1String{fileInfo->fileId});
fileInfoReply.insert("X-OC-MTime", "accepted"); // Prevents Q_ASSERT(!_runningNow) since we'll call PropagateItemJob::done twice in that case.
emit uploadProgress(fileInfo->size, totalSize);
allFileInfoReply.insert(QChar('/') + fileInfo->path(), fileInfoReply);
}
Expand Down Expand Up @@ -977,7 +973,12 @@ QNetworkReply *FakeQNAM::createRequest(QNetworkAccessManager::Operation op, cons
} else if (verb == QLatin1String("GET") || op == QNetworkAccessManager::GetOperation) {
reply = new FakeGetReply { info, op, newRequest, this };
} else if (verb == QLatin1String("PUT") || op == QNetworkAccessManager::PutOperation) {
reply = new FakePutReply { info, op, newRequest, outgoingData->readAll(), this };
if (request.hasRawHeader(QByteArrayLiteral("X-OC-Mtime")) &&
request.rawHeader(QByteArrayLiteral("X-OC-Mtime")).toLongLong() <= 0) {
reply = new FakeErrorReply { op, request, this, 500 };
} else {
reply = new FakePutReply { info, op, newRequest, outgoingData->readAll(), this };
}
} else if (verb == QLatin1String("MKCOL")) {
reply = new FakeMkcolReply { info, op, newRequest, this };
} else if (verb == QLatin1String("DELETE") || op == QNetworkAccessManager::DeleteOperation) {
Expand Down

0 comments on commit c88f57b

Please sign in to comment.