36 lines
1020 B
C++
36 lines
1020 B
C++
// SPDX-License-Identifier: MIT
|
|
|
|
#include "packageutils.h"
|
|
|
|
#include <QTest>
|
|
|
|
class PackageUtilsTest : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
private Q_SLOTS:
|
|
void parsesQueryOutput()
|
|
{
|
|
const auto records = parsePackageRecords(
|
|
"touchpad-hold-tap\t0.1.0-6.fc44\tnoarch\tTouchpad gesture\n"
|
|
"broken line\n");
|
|
|
|
QCOMPARE(records.size(), 1);
|
|
QCOMPARE(records.first().name, QStringLiteral("touchpad-hold-tap"));
|
|
QCOMPARE(records.first().version, QStringLiteral("0.1.0-6.fc44"));
|
|
QCOMPARE(records.first().summary, QStringLiteral("Touchpad gesture"));
|
|
}
|
|
|
|
void validatesPackageNames()
|
|
{
|
|
QVERIFY(isValidPackageName(QStringLiteral("plasma-task-group-shortcuts")));
|
|
QVERIFY(!isValidPackageName(QStringLiteral("--installroot=/tmp")));
|
|
QVERIFY(!isValidPackageName(QStringLiteral("tool; reboot")));
|
|
QVERIFY(!isValidPackageName(QStringLiteral("Tool")));
|
|
}
|
|
};
|
|
|
|
QTEST_MAIN(PackageUtilsTest)
|
|
|
|
#include "test-packageutils.moc"
|