mirror of
https://github.com/parchlinux/calamares.git
synced 2025-07-01 19:35:36 -04:00
[libcalamaresui] Fix up test for logfile
- this test would fail if the logfile already exists for any reason (including "I just ran the test") - remove the file before expecting an empty logfile - improve messages; a missing logfile is not a "things cannot work" situation, it's a warning
This commit is contained in:
parent
cdbc5a7b4b
commit
1998405dbb
2 changed files with 8 additions and 6 deletions
|
@ -28,10 +28,11 @@ using namespace CalamaresUtils::Units;
|
|||
STATICTEST QByteArray
|
||||
logFileContents()
|
||||
{
|
||||
QFile pasteSourceFile( Logger::logFile() );
|
||||
const QString name = Logger::logFile();
|
||||
QFile pasteSourceFile( name );
|
||||
if ( !pasteSourceFile.open( QIODevice::ReadOnly | QIODevice::Text ) )
|
||||
{
|
||||
cError() << "Could not open log file";
|
||||
cWarning() << "Could not open log file" << name;
|
||||
return QByteArray();
|
||||
}
|
||||
QFileInfo fi( pasteSourceFile );
|
||||
|
|
|
@ -35,15 +35,16 @@ private Q_SLOTS:
|
|||
void
|
||||
TestPaste::testGetLogFile()
|
||||
{
|
||||
QFile::remove( Logger::logFile() );
|
||||
// This test assumes nothing **else** has set up logging yet
|
||||
QByteArray b = logFileContents();
|
||||
QVERIFY( b.isEmpty() );
|
||||
QByteArray contentsOfLogfileBefore = logFileContents();
|
||||
QVERIFY( contentsOfLogfileBefore.isEmpty() );
|
||||
|
||||
Logger::setupLogLevel( Logger::LOGDEBUG );
|
||||
Logger::setupLogfile();
|
||||
|
||||
b = logFileContents();
|
||||
QVERIFY( !b.isEmpty() );
|
||||
QByteArray contentsOfLogfileAfterSetup = logFileContents();
|
||||
QVERIFY( !contentsOfLogfileAfterSetup.isEmpty() );
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue