File indexing completed on 2024-06-02 05:06:59
0001 /* 0002 SPDX-FileCopyrightText: 2017-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "restapiutiltest.h" 0008 #include "restapiutil.h" 0009 #include <QTest> 0010 0011 QTEST_GUILESS_MAIN(RestApiUtilTest) 0012 RestApiUtilTest::RestApiUtilTest(QObject *parent) 0013 : QObject(parent) 0014 { 0015 } 0016 0017 void RestApiUtilTest::shouldAdaptUrl_data() 0018 { 0019 QTest::addColumn<QString>("input"); 0020 QTest::addColumn<QString>("output"); 0021 QTest::newRow("empty") << QString() << QString(); 0022 QTest::newRow("withoutscheme") << QStringLiteral("foo.kde.org") << QStringLiteral("https://foo.kde.org"); 0023 QTest::newRow("withhttps") << QStringLiteral("https://foo.kde.org") << QStringLiteral("https://foo.kde.org"); 0024 QTest::newRow("withhttp") << QStringLiteral("http://foo.kde.org") << QStringLiteral("http://foo.kde.org"); 0025 } 0026 0027 void RestApiUtilTest::shouldAdaptUrl() 0028 { 0029 QFETCH(QString, input); 0030 QFETCH(QString, output); 0031 QCOMPARE(RestApiUtil::adaptUrl(input), output); 0032 } 0033 0034 void RestApiUtilTest::shouldUseV1Version() 0035 { 0036 QCOMPARE(RestApiUtil::apiUri(), QStringLiteral("/api/v1/")); 0037 } 0038 0039 #include "moc_restapiutiltest.cpp"