mirror of
https://github.com/chylex/Nextcloud-Desktop.git
synced 2025-02-27 18:45:59 +01:00
Ensure unit test are using absolute paths
This commit is contained in:
parent
1eee5c849e
commit
acd83a2998
@ -150,14 +150,14 @@ void AbstractNetworkJob::adoptRequest(QNetworkReply *reply)
|
||||
QUrl AbstractNetworkJob::makeAccountUrl(const QString &relativePath) const
|
||||
{
|
||||
// ensure we always used the remote folder
|
||||
OC_ASSERT(relativePath.startsWith(QLatin1Char('/')));
|
||||
ASSERT(relativePath.startsWith(QLatin1Char('/')))
|
||||
return Utility::concatUrlPath(_account->url(), relativePath);
|
||||
}
|
||||
|
||||
QUrl AbstractNetworkJob::makeDavUrl(const QString &relativePath) const
|
||||
{
|
||||
// ensure we always used the remote folder
|
||||
OC_ASSERT(relativePath.startsWith(QLatin1Char('/')));
|
||||
ASSERT(relativePath.startsWith(QLatin1Char('/')))
|
||||
return Utility::concatUrlPath(_account->davUrl(), relativePath);
|
||||
}
|
||||
|
||||
|
@ -243,6 +243,15 @@ QString FileInfo::path() const
|
||||
return (parentPath.isEmpty() ? QString() : (parentPath + QLatin1Char('/'))) + name;
|
||||
}
|
||||
|
||||
QString FileInfo::absolutePath() const
|
||||
{
|
||||
if (parentPath.endsWith(QLatin1Char('/'))) {
|
||||
return parentPath + name;
|
||||
} else {
|
||||
return parentPath + QLatin1Char('/') + name;
|
||||
}
|
||||
}
|
||||
|
||||
void FileInfo::fixupParentPathRecursively()
|
||||
{
|
||||
auto p = path();
|
||||
@ -273,7 +282,7 @@ FakePropfindReply::FakePropfindReply(FileInfo &remoteRootFileInfo, QNetworkAcces
|
||||
QMetaObject::invokeMethod(this, "respond404", Qt::QueuedConnection);
|
||||
return;
|
||||
}
|
||||
QString prefix = request.url().path().left(request.url().path().size() - fileName.size());
|
||||
const QString prefix = request.url().path().left(request.url().path().size() - fileName.size());
|
||||
|
||||
// Don't care about the request and just return a full propfind
|
||||
const QString davUri { QStringLiteral("DAV:") };
|
||||
@ -288,11 +297,12 @@ FakePropfindReply::FakePropfindReply(FileInfo &remoteRootFileInfo, QNetworkAcces
|
||||
auto writeFileResponse = [&](const FileInfo &fileInfo) {
|
||||
xml.writeStartElement(davUri, QStringLiteral("response"));
|
||||
|
||||
QString url = prefix + QString::fromUtf8(QUrl::toPercentEncoding(fileInfo.path(), "/"));
|
||||
auto url = QString::fromUtf8(QUrl::toPercentEncoding(fileInfo.absolutePath(), "/"));
|
||||
if (!url.endsWith(QChar('/'))) {
|
||||
url.append(QChar('/'));
|
||||
}
|
||||
xml.writeTextElement(davUri, QStringLiteral("href"), url);
|
||||
const auto href = OCC::Utility::concatUrlPath(prefix, url).path();
|
||||
xml.writeTextElement(davUri, QStringLiteral("href"), href);
|
||||
xml.writeStartElement(davUri, QStringLiteral("propstat"));
|
||||
xml.writeStartElement(davUri, QStringLiteral("prop"));
|
||||
|
||||
@ -488,9 +498,11 @@ FakeGetReply::FakeGetReply(FileInfo &remoteRootFileInfo, QNetworkAccessManager::
|
||||
QString fileName = getFilePathFromUrl(request.url());
|
||||
Q_ASSERT(!fileName.isEmpty());
|
||||
fileInfo = remoteRootFileInfo.find(fileName);
|
||||
if (!fileInfo)
|
||||
qWarning() << "Could not find file" << fileName << "on the remote";
|
||||
QMetaObject::invokeMethod(this, "respond", Qt::QueuedConnection);
|
||||
if (!fileInfo) {
|
||||
qDebug() << "meh;";
|
||||
}
|
||||
Q_ASSERT_X(fileInfo, Q_FUNC_INFO, "Could not find file on the remote");
|
||||
QMetaObject::invokeMethod(this, &FakeGetReply::respond, Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
void FakeGetReply::respond()
|
||||
@ -740,7 +752,7 @@ FakeErrorReply::FakeErrorReply(QNetworkAccessManager::Operation op, const QNetwo
|
||||
open(QIODevice::ReadOnly);
|
||||
setAttribute(QNetworkRequest::HttpStatusCodeAttribute, httpErrorCode);
|
||||
setError(InternalServerError, QStringLiteral("Internal Server Fake Error"));
|
||||
QMetaObject::invokeMethod(this, "respond", Qt::QueuedConnection);
|
||||
QMetaObject::invokeMethod(this, &FakeErrorReply::respond, Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
void FakeErrorReply::respond()
|
||||
|
@ -143,6 +143,7 @@ public:
|
||||
}
|
||||
|
||||
QString path() const;
|
||||
QString absolutePath() const;
|
||||
|
||||
void fixupParentPathRecursively();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user