[users] Tests of config-loading of groups lists

This commit is contained in:
Adriaan de Groot 2020-08-18 17:20:37 +02:00
parent ab3e393d45
commit ecaf97aa60
3 changed files with 51 additions and 0 deletions

View File

@ -21,6 +21,7 @@
#include "JobQueue.h"
#include "utils/Logger.h"
#include "utils/Yaml.h"
#include <QtTest/QtTest>
@ -43,6 +44,9 @@ private Q_SLOTS:
void initTestCase();
void testDefaultGroups();
void testDefaultGroupsYAML_data();
void testDefaultGroupsYAML();
void testHostActions_data();
void testHostActions();
void testPasswordChecks();
@ -112,6 +116,45 @@ UserTests::testDefaultGroups()
}
}
void UserTests::testDefaultGroupsYAML_data()
{
QTest::addColumn< QString >( "filename" );
QTest::addColumn< int >("count");
QTest::addColumn<QString>("group");
QTest::newRow("users.conf") << "users.conf" << 7 << "video";
QTest::newRow("dashed list") << "tests/4-audio.conf" << 4 << "audio";
QTest::newRow("blocked list") << "tests/3-wing.conf" << 3 << "wing";
}
void
UserTests::testDefaultGroupsYAML()
{
if ( !Calamares::JobQueue::instance() )
{
(void)new Calamares::JobQueue();
}
QFETCH(QString, filename);
QFETCH(int, count);
QFETCH(QString, group);
QFile fi( QString("%1/%2").arg(BUILD_AS_TEST, filename) );
QVERIFY(fi.exists());
bool ok = false;
const auto map = CalamaresUtils::loadYaml(fi, &ok);
QVERIFY(ok);
QVERIFY(map.count() > 0);
Config c;
c.setConfigurationMap(map);
QCOMPARE( c.defaultGroups().count(), count);
QVERIFY( c.defaultGroups().contains( group ) );
}
void
UserTests::testHostActions_data()
{

View File

@ -0,0 +1,2 @@
---
defaultGroups: [ wing, wheel, users ]

View File

@ -0,0 +1,6 @@
---
defaultGroups:
- users
- lp
- wheel
- audio