From 0b96ca9f65d9e1557f22cf0f8f3f680d2686f559 Mon Sep 17 00:00:00 2001 From: Laurent Erignoux Date: Sat, 25 Jul 2020 12:09:36 +0800 Subject: [PATCH] Adding unit tests on the new clip --best option --- tests/TestCli.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/TestCli.cpp b/tests/TestCli.cpp index 348afb670d..2fb78d7dee 100644 --- a/tests/TestCli.cpp +++ b/tests/TestCli.cpp @@ -504,6 +504,22 @@ void TestCli::testClip() setInput("a"); execCmd(clipCmd, {"clip", m_dbFile2->fileName(), "--attribute", "Username", "--totp", "/Sample Entry"}); QVERIFY(m_stderr->readAll().contains("ERROR: Please specify one of --attribute or --totp, not both.\n")); + + // Best option + setInput("a"); + execCmd(clipCmd, {"clip", m_dbFile->fileName(), "/Sample", "-b"}); + QCOMPARE(m_stderr->readAll(), QByteArray()); + QCOMPARE(m_stdout->readAll(), QByteArray()); + QVERIFY(clipCmd.name.isEmpty()); + QVERIFY(m_stderr->readAll().contains("Sample Entry")); + QVERIFY(m_stderr->readAll().contains("Sample Entry 1")); + QVERIFY(m_stderr->readAll().contains("Sample Entry 2")); + + setInput("a"); + execCmd(clipCmd, {"clip", m_dbFile->fileName(), "/Entry 1", "-b"}); + QCOMPARE(m_stderr->readAll(), QByteArray()); + QCOMPARE(m_stdout->readAll(), QByteArray()); + QTRY_COMPARE(clipboard->text(), QString("Password")); } void TestCli::testCreate()