Move project save commit planning to app core
This commit is contained in:
@@ -353,6 +353,78 @@ void project_save_write_plan_rejects_missing_paths(pp::tests::Harness& harness)
|
||||
PP_EXPECT(harness, missing_temporary.status().code == pp::foundation::StatusCode::invalid_argument);
|
||||
}
|
||||
|
||||
void project_save_commit_plan_succeeds_for_direct_write(pp::tests::Harness& harness)
|
||||
{
|
||||
const auto plan = pp::app::plan_document_canvas_project_save_commit(
|
||||
pp::app::DocumentCanvasProjectSaveCommitInput {
|
||||
.used_temporary = false,
|
||||
});
|
||||
|
||||
PP_EXPECT(harness, plan.saved);
|
||||
PP_EXPECT(harness, !plan.used_temporary);
|
||||
PP_EXPECT(harness, !plan.target_removed);
|
||||
PP_EXPECT(harness, !plan.temporary_renamed);
|
||||
PP_EXPECT(harness, !plan.target_may_be_missing);
|
||||
PP_EXPECT(harness, plan.log_message == "project saved to target");
|
||||
}
|
||||
|
||||
void project_save_commit_plan_succeeds_for_temporary_swap(pp::tests::Harness& harness)
|
||||
{
|
||||
const auto plan = pp::app::plan_document_canvas_project_save_commit(
|
||||
pp::app::DocumentCanvasProjectSaveCommitInput {
|
||||
.used_temporary = true,
|
||||
.target_remove_attempted = true,
|
||||
.target_remove_succeeded = true,
|
||||
.temporary_rename_attempted = true,
|
||||
.temporary_rename_succeeded = true,
|
||||
});
|
||||
|
||||
PP_EXPECT(harness, plan.saved);
|
||||
PP_EXPECT(harness, plan.used_temporary);
|
||||
PP_EXPECT(harness, plan.target_removed);
|
||||
PP_EXPECT(harness, plan.temporary_renamed);
|
||||
PP_EXPECT(harness, !plan.target_may_be_missing);
|
||||
PP_EXPECT(harness, plan.log_message == "temporary project swapped successfully");
|
||||
}
|
||||
|
||||
void project_save_commit_plan_fails_when_target_remove_fails(pp::tests::Harness& harness)
|
||||
{
|
||||
const auto plan = pp::app::plan_document_canvas_project_save_commit(
|
||||
pp::app::DocumentCanvasProjectSaveCommitInput {
|
||||
.used_temporary = true,
|
||||
.target_remove_attempted = true,
|
||||
.target_remove_succeeded = false,
|
||||
.temporary_rename_attempted = false,
|
||||
.temporary_rename_succeeded = false,
|
||||
});
|
||||
|
||||
PP_EXPECT(harness, !plan.saved);
|
||||
PP_EXPECT(harness, plan.used_temporary);
|
||||
PP_EXPECT(harness, !plan.target_removed);
|
||||
PP_EXPECT(harness, !plan.temporary_renamed);
|
||||
PP_EXPECT(harness, !plan.target_may_be_missing);
|
||||
PP_EXPECT(harness, plan.log_message == "could not remove target project before temporary swap");
|
||||
}
|
||||
|
||||
void project_save_commit_plan_flags_missing_target_after_rename_failure(pp::tests::Harness& harness)
|
||||
{
|
||||
const auto plan = pp::app::plan_document_canvas_project_save_commit(
|
||||
pp::app::DocumentCanvasProjectSaveCommitInput {
|
||||
.used_temporary = true,
|
||||
.target_remove_attempted = true,
|
||||
.target_remove_succeeded = true,
|
||||
.temporary_rename_attempted = true,
|
||||
.temporary_rename_succeeded = false,
|
||||
});
|
||||
|
||||
PP_EXPECT(harness, !plan.saved);
|
||||
PP_EXPECT(harness, plan.used_temporary);
|
||||
PP_EXPECT(harness, plan.target_removed);
|
||||
PP_EXPECT(harness, !plan.temporary_renamed);
|
||||
PP_EXPECT(harness, plan.target_may_be_missing);
|
||||
PP_EXPECT(harness, plan.log_message == "temporary project not swapped after original removal");
|
||||
}
|
||||
|
||||
void snapshot_plan_rejects_invalid_canvas_state(pp::tests::Harness& harness)
|
||||
{
|
||||
const std::uint32_t frames[] { 100U };
|
||||
@@ -540,6 +612,10 @@ int main()
|
||||
harness.run("project save write plan writes direct for new targets", project_save_write_plan_writes_direct_for_new_targets);
|
||||
harness.run("project save write plan prefers temporary for existing targets", project_save_write_plan_prefers_temporary_for_existing_targets);
|
||||
harness.run("project save write plan rejects missing paths", project_save_write_plan_rejects_missing_paths);
|
||||
harness.run("project save commit plan succeeds for direct write", project_save_commit_plan_succeeds_for_direct_write);
|
||||
harness.run("project save commit plan succeeds for temporary swap", project_save_commit_plan_succeeds_for_temporary_swap);
|
||||
harness.run("project save commit plan fails when target remove fails", project_save_commit_plan_fails_when_target_remove_fails);
|
||||
harness.run("project save commit plan flags missing target after rename failure", project_save_commit_plan_flags_missing_target_after_rename_failure);
|
||||
harness.run("snapshot plan rejects invalid canvas state", snapshot_plan_rejects_invalid_canvas_state);
|
||||
harness.run("clear plan records legacy canvas effects", clear_plan_records_legacy_canvas_effects);
|
||||
harness.run("clear plan noops without canvas", clear_plan_noops_without_canvas);
|
||||
|
||||
Reference in New Issue
Block a user