File indexing completed on 2024-04-14 03:54:14

0001 /*
0002     SPDX-FileCopyrightText: 2016 Bhushan Shah <bshah@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include <QCoreApplication>
0008 #include <QDebug>
0009 #include <QUrl>
0010 
0011 int main(int argc, char **argv)
0012 {
0013     QCoreApplication app(argc, argv);
0014     Q_ASSERT(app.arguments().count() == 2);
0015 
0016     const QUrl url(app.arguments().constLast());
0017     Q_ASSERT(url.isValid());
0018     Q_ASSERT(url.scheme() == QLatin1String("mock"));
0019 
0020     // This is very basic dep resolver used for mocking in tests
0021     // if asked to install invalidapp, will fail
0022     // if asked to install validdep, will pass
0023     const QString componentName = url.host();
0024     if (componentName.isEmpty()) {
0025         qWarning() << "wrongly formatted URI" << url;
0026         return 1;
0027     }
0028 
0029     if (componentName == QStringLiteral("invaliddep")) {
0030         qWarning() << "package asked to install invalid dep, bailing out";
0031         return 1;
0032     }
0033 
0034     if (componentName.startsWith(QLatin1String("validdep"))) {
0035         qWarning() << "asked to install valid dep, success!";
0036         return 0;
0037     }
0038 
0039     qWarning() << "Assuming provided package is not available";
0040     return 1;
0041 }