Commit 28fc0fd5 authored by Martin Kampas's avatar Martin Kampas

ut_repomanager: initial commit

parent 08f9289f
......@@ -5,6 +5,7 @@ SUBDIRS = \
testutils/sandboxhook.pro \
ut_coreconfig \
ut_deviceinfo \
ut_repomanager \
ut_rndssucli \
ut_sandbox \
ut_settings \
......
......@@ -13,6 +13,11 @@
<step expected_result="0">/opt/tests/ssu/runtest.sh ut_deviceinfo</step>
</case>
</set>
<set name="repomanager" description="Test to determine if ssu repository management works properly" feature="repomanager">
<case name="ut_repomanager" type="Functional" description="SSU repo management test" timeout="1000" subfeature="">
<step expected_result="0">/opt/tests/ssu/runtest.sh ut_repomanager</step>
</case>
</set>
<set name="rndssucli" description="Test to determine if ssu command line tool works properly" feature="rndssucli">
<case name="ut_rndssucli" type="Functional" description="SSU command line utility test" timeout="1000" subfeature="">
<step expected_result="0">/opt/tests/ssu/runtest.sh ut_rndssucli</step>
......
/**
* @file main.cpp
* @copyright 2012 Jolla Ltd.
* @author Martin Kampas <martin.kampas@tieto.com>
* @date 2012
*/
#include <QtTest/QtTest>
#include "libssu/sandbox_p.h"
#include "repomanagertest.h"
int main(int argc, char **argv){
Sandbox sandbox(QString("%1/configroot").arg(TESTS_DATA_PATH),
Sandbox::UseAsSkeleton, Sandbox::ThisProcess);
if (!sandbox.activate()){
qFatal("Failed to activate sandbox");
}
RepoManagerTest repomanagerTest;
if (QTest::qExec(&repomanagerTest, argc, argv))
return 1;
return 0;
}
/**
* @file repomanagertest.cpp
* @copyright 2013 Jolla Ltd.
* @author Martin Kampas <martin.kampas@tieto.com>
* @date 2013
*/
#include "repomanagertest.h"
#include <QtTest/QtTest>
#include "libssu/ssucoreconfig.h"
#include "libssu/ssurepomanager.h"
void RepoManagerTest::testSettings(){
SsuCoreConfig *const coreConfig = SsuCoreConfig::instance();
SsuRepoManager repoManager;
repoManager.add("repo1", "http://repo1");
QCOMPARE(coreConfig->value("repository-urls/repo1").toString(), QString("http://repo1"));
QVERIFY(!coreConfig->value("enabled-repos").toStringList().contains("repo1"));
QVERIFY(!coreConfig->value("disabled-repos").toStringList().contains("repo1"));
repoManager.enable("repo1");
QCOMPARE(coreConfig->value("repository-urls/repo1").toString(), QString("http://repo1"));
QVERIFY(!coreConfig->value("enabled-repos").toStringList().contains("repo1"));
QVERIFY(!coreConfig->value("disabled-repos").toStringList().contains("repo1"));
repoManager.add("repo1");
QCOMPARE(coreConfig->value("repository-urls/repo1").toString(), QString("http://repo1"));
QVERIFY(coreConfig->value("enabled-repos").toStringList().contains("repo1"));
QVERIFY(!coreConfig->value("disabled-repos").toStringList().contains("repo1"));
repoManager.disable("repo1");
QCOMPARE(coreConfig->value("repository-urls/repo1").toString(), QString("http://repo1"));
QVERIFY(coreConfig->value("enabled-repos").toStringList().contains("repo1"));
QVERIFY(coreConfig->value("disabled-repos").toStringList().contains("repo1"));
repoManager.enable("repo1");
QCOMPARE(coreConfig->value("repository-urls/repo1").toString(), QString("http://repo1"));
QVERIFY(coreConfig->value("enabled-repos").toStringList().contains("repo1"));
QVERIFY(!coreConfig->value("disabled-repos").toStringList().contains("repo1"));
repoManager.add("repo2", "http://repo2");
QCOMPARE(coreConfig->value("repository-urls/repo1").toString(), QString("http://repo1"));
QVERIFY(coreConfig->value("enabled-repos").toStringList().contains("repo1"));
QVERIFY(!coreConfig->value("disabled-repos").toStringList().contains("repo1"));
QCOMPARE(coreConfig->value("repository-urls/repo2").toString(), QString("http://repo2"));
QVERIFY(!coreConfig->value("enabled-repos").toStringList().contains("repo2"));
QVERIFY(!coreConfig->value("disabled-repos").toStringList().contains("repo2"));
repoManager.disable("repo2");
QCOMPARE(coreConfig->value("repository-urls/repo1").toString(), QString("http://repo1"));
QVERIFY(coreConfig->value("enabled-repos").toStringList().contains("repo1"));
QVERIFY(!coreConfig->value("disabled-repos").toStringList().contains("repo1"));
QCOMPARE(coreConfig->value("repository-urls/repo2").toString(), QString("http://repo2"));
QVERIFY(!coreConfig->value("enabled-repos").toStringList().contains("repo2"));
QVERIFY(coreConfig->value("disabled-repos").toStringList().contains("repo2"));
repoManager.enable("repo2");
QCOMPARE(coreConfig->value("repository-urls/repo1").toString(), QString("http://repo1"));
QVERIFY(coreConfig->value("enabled-repos").toStringList().contains("repo1"));
QVERIFY(!coreConfig->value("disabled-repos").toStringList().contains("repo1"));
QCOMPARE(coreConfig->value("repository-urls/repo2").toString(), QString("http://repo2"));
QVERIFY(!coreConfig->value("enabled-repos").toStringList().contains("repo2"));
QVERIFY(!coreConfig->value("disabled-repos").toStringList().contains("repo2"));
repoManager.add("repo2");
QCOMPARE(coreConfig->value("repository-urls/repo1").toString(), QString("http://repo1"));
QVERIFY(coreConfig->value("enabled-repos").toStringList().contains("repo1"));
QVERIFY(!coreConfig->value("disabled-repos").toStringList().contains("repo1"));
QCOMPARE(coreConfig->value("repository-urls/repo2").toString(), QString("http://repo2"));
QVERIFY(coreConfig->value("enabled-repos").toStringList().contains("repo2"));
QVERIFY(!coreConfig->value("disabled-repos").toStringList().contains("repo2"));
repoManager.remove("repo1");
QVERIFY(!coreConfig->contains("repository-urls/repo1"));
QVERIFY(!coreConfig->value("enabled-repos").toStringList().contains("repo1"));
QVERIFY(!coreConfig->value("disabled-repos").toStringList().contains("repo1"));
QCOMPARE(coreConfig->value("repository-urls/repo2").toString(), QString("http://repo2"));
QVERIFY(coreConfig->value("enabled-repos").toStringList().contains("repo2"));
QVERIFY(!coreConfig->value("disabled-repos").toStringList().contains("repo2"));
repoManager.remove("repo2");
QVERIFY(!coreConfig->contains("repository-urls/repo1"));
QVERIFY(!coreConfig->value("enabled-repos").toStringList().contains("repo1"));
QVERIFY(!coreConfig->value("disabled-repos").toStringList().contains("repo1"));
QVERIFY(!coreConfig->contains("repository-urls/repo2"));
QVERIFY(!coreConfig->value("enabled-repos").toStringList().contains("repo2"));
QVERIFY(!coreConfig->value("disabled-repos").toStringList().contains("repo2"));
}
/**
* @file repomanagertest.h
* @copyright 2013 Jolla Ltd.
* @author Martin Kampas <martin.kampas@tieto.com>
* @date 2013
*/
#ifndef _REPOMANAGERTEST_H
#define _REPOMANAGERTEST_H
#include <QObject>
class RepoManagerTest: public QObject {
Q_OBJECT
private slots:
void testSettings();
};
#endif
[General]
initialized=true
flavour=testing
registered=false
rndRelease=next
release=latest
adaptation=
ca-certificate=
credentials-scope=example
credentials-url-example = http://creden.tia.ls/
[repository-urls]
[repository-url-variables]
TARGET = ut_repomanager
include(../testapplication.pri)
include(ut_repomanager_dependencies.pri)
HEADERS = \
repomanagertest.h \
SOURCES = \
main.cpp \
repomanagertest.cpp \
test_data_etc.files = \
testdata/ssu.ini \
test_data_usr_share.files = \
testdata/ssu-defaults.ini \
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment