Skip to content

Commit

Permalink
ut_repomanager: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
martyone committed Apr 10, 2013
1 parent 08f9289 commit 28fc0fd
Show file tree
Hide file tree
Showing 9 changed files with 175 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/tests.pro
Expand Up @@ -5,6 +5,7 @@ SUBDIRS = \
testutils/sandboxhook.pro \
ut_coreconfig \
ut_deviceinfo \
ut_repomanager \
ut_rndssucli \
ut_sandbox \
ut_settings \
Expand Down
5 changes: 5 additions & 0 deletions tests/tests.xml
Expand Up @@ -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>
Expand Down
26 changes: 26 additions & 0 deletions tests/ut_repomanager/main.cpp
@@ -0,0 +1,26 @@
/**
* @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;
}
91 changes: 91 additions & 0 deletions tests/ut_repomanager/repomanagertest.cpp
@@ -0,0 +1,91 @@
/**
* @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"));
}
20 changes: 20 additions & 0 deletions tests/ut_repomanager/repomanagertest.h
@@ -0,0 +1,20 @@
/**
* @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
1 change: 1 addition & 0 deletions tests/ut_repomanager/testdata/ssu-defaults.ini
@@ -0,0 +1 @@
# empty
14 changes: 14 additions & 0 deletions tests/ut_repomanager/testdata/ssu.ini
@@ -0,0 +1,14 @@
[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]
16 changes: 16 additions & 0 deletions tests/ut_repomanager/ut_repomanager.pro
@@ -0,0 +1,16 @@
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 \
1 change: 1 addition & 0 deletions tests/ut_repomanager/ut_repomanager_dependencies.pri
@@ -0,0 +1 @@
include(../../libssu/libssu.pri)

0 comments on commit 28fc0fd

Please sign in to comment.