Commit 8c6d4bb9 authored by Aard's avatar Aard

[tests] Add testcases for repository selection, JB#31869

Repository selection in relation to device modes was not properly tested
so far. Having this tested is especially important for making sure
introducing repository isolation does not break anything -- and future
changes don't break repository isolation.
parent d402afe8
......@@ -3,6 +3,8 @@
* @copyright 2013 Jolla Ltd.
* @author Martin Kampas <martin.kampas@tieto.com>
* @date 2013
* @todo simulate device specific repos via boardmappings
* @todo test repository filtering
*/
#include "repomanagertest.h"
......@@ -12,6 +14,11 @@
#include "libssu/ssucoreconfig_p.h"
#include "libssu/ssurepomanager.h"
void RepoManagerTest::initTestCase(){
rndRepos << "mer-core" << "adaptation" << "nemo" << "non-oss" << "oss";
releaseRepos << "vendor" << "apps";
}
void RepoManagerTest::testSettings(){
SsuCoreConfig *const coreConfig = SsuCoreConfig::instance();
SsuRepoManager repoManager;
......@@ -89,3 +96,92 @@ void RepoManagerTest::testSettings(){
QVERIFY(!coreConfig->value("enabled-repos").toStringList().contains("repo2"));
QVERIFY(!coreConfig->value("disabled-repos").toStringList().contains("repo2"));
}
void RepoManagerTest::testCustomRepos(){
SsuCoreConfig *const coreConfig = SsuCoreConfig::instance();
SsuRepoManager repoManager;
QStringList customRepos;
QSet<QString> set;
repoManager.add("r1", "http://localhost/r1/");
repoManager.add("r2", "http://localhost/r2/");
customRepos << "r1" << "r2";
QCOMPARE(releaseRepos.toSet().count(), 2);
// check default release repos + custom repos
coreConfig->setDeviceMode(Ssu::ReleaseMode, Ssu::Replace);
QCOMPARE(coreConfig->deviceMode(), Ssu::ReleaseMode);
set = releaseRepos.toSet().unite(repoManager.repos().toSet());
QCOMPARE(set.count(), 4);
QVERIFY(set == customRepos.toSet().unite(releaseRepos.toSet()));
// check default rnd repos + custom repos
coreConfig->setDeviceMode(Ssu::RndMode, Ssu::Replace);
QCOMPARE(coreConfig->deviceMode(), Ssu::RndMode);
set = rndRepos.toSet().unite(repoManager.repos().toSet());
QCOMPARE(set.count(), 7);
QVERIFY(set == customRepos.toSet().unite(rndRepos.toSet()));
// enable store repository as preconfigured custom repo
customRepos << "store";
repoManager.add("store");
set = rndRepos.toSet().unite(repoManager.repos().toSet());
QCOMPARE(set.count(), 8);
QVERIFY(set == customRepos.toSet().unite(rndRepos.toSet()));
// check store repo with release mode
coreConfig->setDeviceMode(Ssu::ReleaseMode, Ssu::Replace);
QCOMPARE(coreConfig->deviceMode(), Ssu::ReleaseMode);
set = releaseRepos.toSet().unite(repoManager.repos().toSet());
QCOMPARE(set.count(), 5);
QVERIFY(set == customRepos.toSet().unite(releaseRepos.toSet()));
// check repositories in update mode
// store + other custom repositories should be gone
coreConfig->setDeviceMode(Ssu::UpdateMode, Ssu::Add);
QCOMPARE(coreConfig->deviceMode(), Ssu::ReleaseMode | Ssu::UpdateMode);
QVERIFY(releaseRepos.toSet() == repoManager.repos().toSet());
// check rndmode + update mode
coreConfig->setDeviceMode(Ssu::RndMode, Ssu::Add);
QCOMPARE(coreConfig->deviceMode(), Ssu::ReleaseMode | Ssu::UpdateMode | Ssu::RndMode);
QVERIFY(rndRepos.toSet() == repoManager.repos().toSet());
coreConfig->setDeviceMode(Ssu::RndMode | Ssu::UpdateMode, Ssu::Replace);
QCOMPARE(coreConfig->deviceMode(), Ssu::UpdateMode | Ssu::RndMode);
QVERIFY(rndRepos.toSet() == repoManager.repos().toSet());
}
void RepoManagerTest::testRepos(){
SsuCoreConfig *const coreConfig = SsuCoreConfig::instance();
SsuRepoManager repoManager;
QSet<QString> set;
// first, check if the repository lists are correct by explicitely
// specifying rnd and release modes
set = rndRepos.toSet().subtract(repoManager.repos(true).toSet());
QVERIFY(set.isEmpty());
set = releaseRepos.toSet().subtract(repoManager.repos(false).toSet());
QVERIFY(set.isEmpty());
// second, check if changing the device mode in the configuration
// properly switches between modes
coreConfig->setDeviceMode(Ssu::ReleaseMode, Ssu::Replace);
QCOMPARE(coreConfig->deviceMode(), Ssu::ReleaseMode);
set = releaseRepos.toSet().subtract(repoManager.repos().toSet());
QVERIFY(set.isEmpty());
// both adding rnd-mode on top of release mode, and setting it
// to rnd mode only should switch the device to rnd mode
coreConfig->setDeviceMode(Ssu::RndMode, Ssu::Add);
QCOMPARE(coreConfig->deviceMode(), Ssu::ReleaseMode | Ssu::RndMode);
set = rndRepos.toSet().subtract(repoManager.repos().toSet());
QVERIFY(set.isEmpty());
coreConfig->setDeviceMode(Ssu::RndMode, Ssu::Replace);
QCOMPARE(coreConfig->deviceMode(), Ssu::RndMode);
set = rndRepos.toSet().subtract(repoManager.repos().toSet());
QVERIFY(set.isEmpty());
}
......@@ -9,12 +9,19 @@
#define _REPOMANAGERTEST_H
#include <QObject>
#include <QStringList>
class RepoManagerTest: public QObject {
Q_OBJECT
private slots:
void initTestCase();
void testSettings();
void testCustomRepos();
void testRepos();
private:
QStringList rndRepos, releaseRepos;
};
#endif
[all]
credentials=vendor
credentials-url=https://%(ssuRegDomain)/%(ssuRegPath)/%1/credentials.xml
register-url=https://%(ssuRegDomain)/%(ssuRegPath)/%1/register.xml
store=https://%(packagesDomain)/store/
[release]
vendor=https://%(packagesDomain)/releases/%(release)/vendor/%(arch)/
apps=https://%(packagesDomain)/releases/%(release)/vendor-apps/%(arch)/
[rnd]
mer-core=https://%(packagesDomain)/mer/%(release)/builds/%(arch)/%(debugSplit)/
adaptation=https://%(packagesDomain)/nemo/%(release)/adaptation-%(deviceFamily)/%(arch)/
nemo=https://%(packagesDomain)/nemo/%(release)/platform/%(arch)/
non-oss=https://%(dumpDomain)/pj:/non-oss%(flavour)/%(release)_%(arch)/
oss=https://%(dumpDomain)/pj:/oss%(flavour)/%(release)_%(arch)/
[devel-flavour]
flavour-pattern=
[release-flavour]
flavour-pattern=:/release
[testing-flavour]
flavour-pattern=:/testing
[example-domain]
dumpDomain=dump.example.com
packagesDomain=packages.example.com
ssuRegDomain=ssu.example.com
ssuRegPath=ssu/device
# fallback if domain is not matched or not set
[default-domain]
dumpDomain=dump.testing.com
packagesDomain=packages.testing.com
ssuRegDomain=ssu.testing.com
ssuRegPath=ssu/device
[default-repos]
release=vendor,apps
rnd=mer-core,adaptation,nemo,non-oss,oss
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