╭ changed ───────────────╮ │src/test/event/patch.zig│ ╰────────────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │646 try std.testing.expect(null != try evt.PatchRev.readById(Repo.DB, repo_opts.hash, moment, &arena, &first_patchrev_id)); │ │647 } │ │648 try std.testing.expectError(error.NotFound, evt.currentMoment(repo_opts, &target)); │ │649 + │ │650 + // │ │651 + // publish another draft before its first push │ │652 + // │ │653 + │ │654 + const unpushed_id = evt.EventWithId.randomId(prng.random()); │ │655 + const unpushed_id_hex = std.fmt.bytesToHex(unpushed_id, .lower); │ │656 + const unpushed_path = try fork.create(repo_opts, io, allocator, repos_dir, &admin, .{ │ │657 + .id = unpushed_id_hex, │ │658 + .user_id = user_id, │ │659 + .repo_id = repo_id, │ │660 + .title = "explain the answer", │ │661 + .tags = "documentation", │ │662 + .description = "describes the existing answer", │ │663 + .author = author, │ │664 + .timestamp = 3, │ │665 + }); │ │666 + defer allocator.free(unpushed_path); │ │667 + try pch.publish(repo_opts, io, allocator, &admin, &target, unpushed_path, .{ │ │668 + .id = unpushed_id_hex, │ │669 + .user_id = user_id, │ │670 + .repo_id = repo_id, │ │671 + .author = author, │ │672 + .timestamp = 4, │ │673 + }); │ │674 + { │ │675 + var verify_arena = std.heap.ArenaAllocator.init(allocator); │ │676 + defer verify_arena.deinit(); │ │677 + const target_moment = try evt.currentMoment(repo_opts, &target); │ │678 + const unpushed = (try evt.Patch.readById(Repo.DB, repo_opts.hash, target_moment, &verify_arena, &unpushed_id)) orelse return error.NotFound;│ │679 + try std.testing.expectEqual(null, unpushed.event.revision); │ │680 + │ │681 + var unpushed_repo = try Repo.open(io, allocator, .{ .path = unpushed_path }); │ │682 + defer unpushed_repo.deinit(io, allocator); │ │683 + const fork_moment = try evt.currentMoment(repo_opts, &unpushed_repo); │ │684 + const removed = (try evt.Patch.readById(Repo.DB, repo_opts.hash, fork_moment, &verify_arena, &unpushed_id)) orelse return error.NotFound; │ │685 + try std.testing.expect(removed.removed); │ │686 + } │ │687 │ │688 // │ │689 // edit the patch metadata in the fork │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │735 try std.testing.expectEqual(.publish, published_fork.event.stage); │ │736 const draft_key = evt.Fork.draftKey(&repo_id, &user_id); │ │737 try std.testing.expectEqual(0, try indexedForkCount(admin_moment, evt.Fork.repo_user_to_draft_id_set_key, &draft_key));│ │700 - try std.testing.expectEqual(1, try indexedForkCount(admin_moment, evt.Fork.user_id_to_fork_id_set_key, &user_id)); │ │738 + try std.testing.expectEqual(2, try indexedForkCount(admin_moment, evt.Fork.user_id_to_fork_id_set_key, &user_id)); │ │739 var squash_oid: [hash.hexLen(repo_opts.hash)]u8 = undefined; │ │740 { │ │741 var draft = try Repo.open(io, allocator, .{ .path = draft_path }); │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯