ssu
Loading...
Searching...
No Matches
ssuurlresolvertest.cpp
Go to the documentation of this file.
1
7
9
10#include <stdlib.h>
11#include <zypp/media/UrlResolverPlugin.h>
12
13#include <QtTest/QtTest>
14
15#include "libssu/sandbox_p.h"
16
23
24void SsuUrlResolverTest::initTestCase()
25{
26 m_sandbox = new Sandbox(QString("%1/configroot").arg(LOCATE_DATA_PATH),
27 Sandbox::UseDirectly, Sandbox::ChildProcesses);
28 if (!m_sandbox->activate()) {
29 QFAIL("Failed to activate sandbox");
30 }
31 if (getenv("SSU_SANDBOX_PATH")) {
32 qDebug() << "Using in-tree sandbox";
33 setenv("LD_PRELOAD", getenv("SSU_SANDBOX_PATH"), 1);
34 } else
35 setenv("LD_PRELOAD", SSU_SANDBOX_PATH, 1);
36}
37
38void SsuUrlResolverTest::cleanupTestCase()
39{
40 delete m_sandbox;
41 m_sandbox = 0;
42}
43
44void SsuUrlResolverTest::test_data()
45{
46 QTest::addColumn<QString>("input");
47 QTest::addColumn<QString>("expected");
48
49 QTest::newRow("basic")
50 << "plugin:ssu?repo=mer-core&debug&arch=i586"
51 << "https://packages.testing.com//mer/i586/debug/";
52}
53
54void SsuUrlResolverTest::test()
55{
56 QFETCH(QString, input);
57 QFETCH(QString, expected);
58
59 zypp::media::UrlResolverPlugin::HeaderList customHeaders;
60 const QString resolved = QString::fromStdString(
61 zypp::media::UrlResolverPlugin::resolveUrl(input.toStdString(), customHeaders).asString());
62
63 QCOMPARE(resolved, expected);
64}