Skip to content

Commit

Permalink
Fix the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
louib committed Aug 21, 2022
1 parent 46486f4 commit aa415e5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/cli/DatabaseEdit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,16 @@
#include <QCommandLineParser>
#include <QFileInfo>

const QCommandLineOption DatabaseEdit::SetKeyFileOption =
QCommandLineOption(QStringList() << "set-key-file",
QObject::tr("Set the key file for the database."),
QObject::tr("path"));

DatabaseEdit::DatabaseEdit()
{
name = QString("db-edit");
description = QObject::tr("Edit a database.");
positionalArguments.append({QString("database"), QObject::tr("Path of the database."), QString("")});
options.append(Create::SetKeyFileOption);
options.append(DatabaseEdit::SetKeyFileOption);
options.append(Create::SetPasswordOption);
options.append(Create::DecryptionTimeOption);
}
Expand Down
2 changes: 2 additions & 0 deletions src/cli/DatabaseEdit.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ class DatabaseEdit : public DatabaseCommand

int executeWithDatabase(QSharedPointer<Database> db, QSharedPointer<QCommandLineParser> parser) override;

static const QCommandLineOption SetKeyFileOption;

private:
QSharedPointer<CompositeKey>
getNewDatabaseKey(QSharedPointer<Database> database, bool updatePassword, QString newFileKeyPath);
Expand Down
4 changes: 2 additions & 2 deletions tests/TestCli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "cli/AttachmentRemove.h"
#include "cli/Clip.h"
#include "cli/Create.h"
#include "cli/DatabaseEdit.h"
#include "cli/Diceware.h"
#include "cli/Edit.h"
#include "cli/Estimate.h"
Expand Down Expand Up @@ -850,7 +851,7 @@ void TestCli::testCreate()
void TestCli::testDatabaseEdit()
{
Create createCmd;
Edit editCmd;
DatabaseEdit editCmd;
QVERIFY(!createCmd.name.isEmpty());
QVERIFY(createCmd.getDescriptionLine().contains(createCmd.name));

Expand All @@ -870,7 +871,6 @@ void TestCli::testDatabaseEdit()

setInput({"a", "b", "b"});
execCmd(editCmd, {"db-edit", dbFilename, "-p"});
QCOMPARE(m_stderr->readLine(), QByteArray(""));
QCOMPARE(m_stdout->readAll(), QByteArray("Successfully edited the database.\n"));

db = readDatabase(dbFilename, "b");
Expand Down

0 comments on commit aa415e5

Please sign in to comment.