Skip to content

Latest commit

 

History

History
60 lines (48 loc) · 1.59 KB

ssuurlresolvertest.cpp

File metadata and controls

60 lines (48 loc) · 1.59 KB
 
Apr 2, 2013
Apr 2, 2013
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/**
* @file ssuurlresolvertest.cpp
* @copyright 2013 Jolla Ltd.
* @author Martin Kampas <martin.kampas@tieto.com>
* @date 2013
*/
#include "ssuurlresolvertest.h"
#include <stdlib.h>
#include <zypp/media/UrlResolverPlugin.h>
#include <QtTest/QtTest>
May 24, 2013
May 24, 2013
15
16
#include "libssu/sandbox_p.h"
Apr 2, 2013
Apr 2, 2013
17
18
19
20
21
22
23
24
/**
* @class SsuUrlResolverTest
* @brief Tests libzypp UrlResolverPlugin plugin compatibility
*
* This test verifies the UrlResolverPlugin works well with installed version of libzypp.
*/
void SsuUrlResolverTest::initTestCase(){
Aug 21, 2015
Aug 21, 2015
25
m_sandbox = new Sandbox(QString("%1/configroot").arg(LOCATE_DATA_PATH),
May 24, 2013
May 24, 2013
26
27
28
29
Sandbox::UseDirectly, Sandbox::ChildProcesses);
if (!m_sandbox->activate()){
QFAIL("Failed to activate sandbox");
}
Aug 21, 2015
Aug 21, 2015
30
31
32
33
34
if (getenv("SSU_SANDBOX_PATH")){
qDebug() << "Using in-tree sandbox";
setenv("LD_PRELOAD", getenv("SSU_SANDBOX_PATH"), 1);
} else
setenv("LD_PRELOAD", qPrintable(QString("%1/libsandboxhook.so").arg(TESTS_PATH)), 1);
May 24, 2013
May 24, 2013
35
36
37
38
39
}
void SsuUrlResolverTest::cleanupTestCase(){
delete m_sandbox;
m_sandbox = 0;
Apr 2, 2013
Apr 2, 2013
40
41
42
43
44
45
46
47
}
void SsuUrlResolverTest::test_data(){
QTest::addColumn<QString>("input");
QTest::addColumn<QString>("expected");
QTest::newRow("basic")
<< "plugin:ssu?repo=mer-core&debug&arch=i586"
May 24, 2013
May 24, 2013
48
<< "https://packages.testing.com//mer/i586/debug/";
Apr 2, 2013
Apr 2, 2013
49
50
51
52
53
54
55
56
57
58
59
60
}
void SsuUrlResolverTest::test(){
QFETCH(QString, input);
QFETCH(QString, expected);
zypp::media::UrlResolverPlugin::HeaderList customHeaders;
const QString resolved = QString::fromStdString(
zypp::media::UrlResolverPlugin::resolveUrl(input.toStdString(), customHeaders).asString());
QCOMPARE(resolved, expected);
}