[preservefiles] Expand tests with reading some existing config-items
This commit is contained in:
parent
a1b7ba0dc5
commit
3be52f8b37
@ -12,6 +12,7 @@
|
||||
#include "Settings.h"
|
||||
#include "utils/CalamaresUtilsSystem.h"
|
||||
#include "utils/Logger.h"
|
||||
#include "utils/NamedEnum.h"
|
||||
#include "utils/Yaml.h"
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
@ -26,14 +27,8 @@ public:
|
||||
private Q_SLOTS:
|
||||
void initTestCase();
|
||||
|
||||
/*
|
||||
void testOneUrl();
|
||||
void testUrls_data();
|
||||
void testUrls();
|
||||
|
||||
void testBadConfigDoesNotResetUrls();
|
||||
*/
|
||||
void testTrue();
|
||||
void testItems_data();
|
||||
void testItems();
|
||||
};
|
||||
|
||||
PreserveFilesTests::PreserveFilesTests() {}
|
||||
@ -57,11 +52,39 @@ PreserveFilesTests::initTestCase()
|
||||
}
|
||||
|
||||
void
|
||||
PreserveFilesTests::testTrue()
|
||||
PreserveFilesTests::testItems_data()
|
||||
{
|
||||
QVERIFY( true );
|
||||
QTest::addColumn< QString >( "filename" );
|
||||
QTest::addColumn< bool >( "ok" );
|
||||
QTest::addColumn< int >( "type_i" );
|
||||
|
||||
QTest::newRow( "log " ) << QString( "1a-log.conf" ) << true << smash( ItemType::Log );
|
||||
QTest::newRow( "config " ) << QString( "1b-config.conf" ) << true << smash( ItemType::Config );
|
||||
QTest::newRow( "src " ) << QString( "1c-src.conf" ) << true << smash( ItemType::Path );
|
||||
QTest::newRow( "filename" ) << QString( "1d-filename.conf" ) << true << smash( ItemType::Path );
|
||||
QTest::newRow( "empty " ) << QString( "1e-empty.conf" ) << false << smash( ItemType::None );
|
||||
QTest::newRow( "bad " ) << QString( "1f-bad.conf" ) << false << smash( ItemType::None );
|
||||
}
|
||||
|
||||
void
|
||||
PreserveFilesTests::testItems()
|
||||
{
|
||||
QFETCH( QString, filename );
|
||||
QFETCH( bool, ok );
|
||||
QFETCH( int, type_i );
|
||||
|
||||
QFile fi( QString( "%1/tests/%2" ).arg( BUILD_AS_TEST, filename ) );
|
||||
QVERIFY( fi.exists() );
|
||||
|
||||
bool config_file_ok = false;
|
||||
const auto map = CalamaresUtils::loadYaml( fi, &config_file_ok );
|
||||
QVERIFY( config_file_ok );
|
||||
|
||||
CalamaresUtils::Permissions perm( QStringLiteral( "adridg:adridg:0750" ) );
|
||||
auto i = Item::fromVariant( map[ "item" ], perm );
|
||||
QCOMPARE( bool( i ), ok );
|
||||
QCOMPARE( smash( i.type() ), type_i );
|
||||
}
|
||||
|
||||
QTEST_GUILESS_MAIN( PreserveFilesTests )
|
||||
|
||||
|
7
src/modules/preservefiles/tests/1a-log.conf
Normal file
7
src/modules/preservefiles/tests/1a-log.conf
Normal file
@ -0,0 +1,7 @@
|
||||
# SPDX-FileCopyrightText: no
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
#
|
||||
item:
|
||||
from: log
|
||||
dest: /var/log/Calamares.log
|
||||
perm: root:wheel:601
|
6
src/modules/preservefiles/tests/1b-config.conf
Normal file
6
src/modules/preservefiles/tests/1b-config.conf
Normal file
@ -0,0 +1,6 @@
|
||||
# SPDX-FileCopyrightText: no
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
item:
|
||||
from: config
|
||||
dest: /var/log/Calamares-install.json
|
||||
perm: root:wheel:600
|
6
src/modules/preservefiles/tests/1c-src.conf
Normal file
6
src/modules/preservefiles/tests/1c-src.conf
Normal file
@ -0,0 +1,6 @@
|
||||
# SPDX-FileCopyrightText: no
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
item:
|
||||
src: /root/.cache/calamares/session.log
|
||||
dest: /var/log/Calamares.log
|
||||
perm: root:wheel:600
|
6
src/modules/preservefiles/tests/1d-filename.conf
Normal file
6
src/modules/preservefiles/tests/1d-filename.conf
Normal file
@ -0,0 +1,6 @@
|
||||
# SPDX-FileCopyrightText: no
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
item:
|
||||
src: /root/.cache/calamares/session.log
|
||||
dest: /var/log/Calamares.log
|
||||
perm: root:wheel:600
|
3
src/modules/preservefiles/tests/1e-empty.conf
Normal file
3
src/modules/preservefiles/tests/1e-empty.conf
Normal file
@ -0,0 +1,3 @@
|
||||
# SPDX-FileCopyrightText: no
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
item: []
|
4
src/modules/preservefiles/tests/1f-bad.conf
Normal file
4
src/modules/preservefiles/tests/1f-bad.conf
Normal file
@ -0,0 +1,4 @@
|
||||
# SPDX-FileCopyrightText: no
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
item:
|
||||
bop: 1
|
Loading…
Reference in New Issue
Block a user