Skip to content

Commit bf3576d

Browse files
committed
test(controllers): match relaxed validation message in testValidationRejectsExistingDestDir
Commit e6caf85 ("feat(controller): allow OpenNotebookController clone into non-existing or empty dest") relaxed validateCloneInput's dest predicate from "must NOT exist" to "non-existing OR existing empty directory", and changed the rejection message accordingly. The test testValidationRejectsExistingDestDir still asserted the OLD message substring ("already exists") and was failing with validation message must mention 'already exists' (got: Local root folder must be empty (contains 1 item(s)).) The test's setup already creates a non-empty dest dir (with a sentinel file), so the test's intent is still valid: NON-EMPTY existing dirs must be rejected. Only the assertion substring needed updating to "must be empty". The renamed local var (already_exists -> non_empty_exists) and the expanded comment now correctly reflect the post-e6caf855 behavior contract.
1 parent a1edeba commit bf3576d

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

tests/controllers/test_open_notebook_controller_clone.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,14 @@ void TestOpenNotebookControllerClone::testValidationRejectsExistingDestDir() {
321321
TempDirFixture localTemp;
322322
QVERIFY(localTemp.isValid());
323323

324-
// Pre-create the user-chosen destination -- validateCloneInput must reject.
325-
const QString existingDestDir = localTemp.filePath(QStringLiteral("already_exists"));
324+
// Pre-create the user-chosen destination as a NON-EMPTY dir --
325+
// validateCloneInput must reject. Per commit e6caf855 ("allow
326+
// OpenNotebookController clone into non-existing or empty dest"), EMPTY
327+
// existing dirs are now accepted (the worker rmdirs them before the
328+
// staging->final rename); only NON-EMPTY existing dirs are rejected. The
329+
// sentinel file below both verifies post-rollback safety AND makes the dir
330+
// non-empty, which is what triggers the validation failure tested here.
331+
const QString existingDestDir = localTemp.filePath(QStringLiteral("non_empty_exists"));
326332
QVERIFY(QDir().mkpath(existingDestDir));
327333
// Add a sentinel file so we can confirm we don't touch it on rollback.
328334
QFile sentinel(existingDestDir + QStringLiteral("/sentinel.txt"));
@@ -338,9 +344,9 @@ void TestOpenNotebookControllerClone::testValidationRejectsExistingDestDir() {
338344
OpenNotebookController controller(m_services);
339345
// Pre-flight validate: synchronous answer, no worker dispatch.
340346
const auto validation = controller.validateCloneInput(input);
341-
QVERIFY2(!validation.valid, "existing dest dir must be rejected by validation");
342-
QVERIFY2(validation.message.contains(QStringLiteral("already exists")),
343-
qPrintable(QStringLiteral("validation message must mention 'already exists' (got: %1)")
347+
QVERIFY2(!validation.valid, "non-empty existing dest dir must be rejected by validation");
348+
QVERIFY2(validation.message.contains(QStringLiteral("must be empty")),
349+
qPrintable(QStringLiteral("validation message must mention 'must be empty' (got: %1)")
344350
.arg(validation.message)));
345351

346352
// cloneAndOpen with the same input must short-circuit through

0 commit comments

Comments
 (0)