╭ changed ───────────────╮ │src/test/event/patch.zig│ ╰────────────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │842 .password_hash = "", │ │843 } }, │ │844 }, │ │845 + }); │ │846 + const user_repo_path = try evt.userRepoPath(allocator, repos_dir, &user_id); │ │847 + defer allocator.free(user_repo_path); │ │848 + var user_repo = try evt.initUserRepo(io, allocator, user_repo_path); │ │849 + defer user_repo.deinit(io, allocator); │ │850 + try evt.consume(.server, .user, .xit, evt.user_repo_opts, io, allocator, &user_repo, evt.events_ref, &.{│ │851 .{ │ │852 .id = repo_id_hex, │ │853 .timestamp = 1, │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────╮ │882 │ │883 const patch_id = evt.EventWithId.randomId(prng.random()); │ │884 const patch_id_hex = std.fmt.bytesToHex(patch_id, .lower); │ │879 - const draft_path = try fork.create(repo_opts, io, allocator, repos_dir, &admin, .{ │ │885 + const draft_path = try fork.create(repo_opts, io, allocator, repos_dir, &user_repo, .{│ │886 .target_branch = "master", │ │887 .id = patch_id_hex, │ │888 .user_id = user_id, │ ╰───────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────╮ │889 .repo_id = repo_id, │ │890 + .repo_user_id = user_id, │ │891 .title = "add the answer", │ │892 .labels = "enhancement", │ │893 .description = "adds a reusable answer constant",│ ╰──────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────╮ │968 │ │969 const unpushed_id = evt.EventWithId.randomId(prng.random()); │ │970 const unpushed_id_hex = std.fmt.bytesToHex(unpushed_id, .lower); │ │964 - const unpushed_path = try fork.create(repo_opts, io, allocator, repos_dir, &admin, .{ │ │971 + const unpushed_path = try fork.create(repo_opts, io, allocator, repos_dir, &user_repo, .{│ │972 .id = unpushed_id_hex, │ │973 .user_id = user_id, │ │974 .repo_id = repo_id, │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────╮ │975 + .repo_user_id = user_id, │ │976 .title = "explain the answer", │ │977 .labels = "documentation", │ │978 .description = "describes the existing answer",│ ╰────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────╮ │981 .timestamp = 3, │ │982 }); │ │983 defer allocator.free(unpushed_path); │ │976 - try pch.publish(repo_opts, io, allocator, &admin, &target, unpushed_path, .{ │ │984 + try pch.publish(repo_opts, io, allocator, &admin, &user_repo, &target, unpushed_path, .{│ │985 .id = unpushed_id_hex, │ │986 .user_id = user_id, │ │987 .repo_id = repo_id, │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │1006 // edit the patch metadata in the fork │ │1007 // │ │1008 │ │1001 - try std.testing.expect(try pch.editDraft(repo_opts, io, allocator, &admin, draft_path, .{ │ │1009 + try std.testing.expect(try pch.editDraft(repo_opts, io, allocator, &admin, &user_repo, draft_path, .{│ │1010 .id = patch_id_hex, │ │1011 .user_id = user_id, │ │1012 .repo_id = repo_id, │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────╮ │1023 // │ │1024 │ │1025 const before_publish = try target.core.db.rootCursor().count(); │ │1018 - try pch.publish(repo_opts, io, allocator, &admin, &target, draft_path, .{ │ │1026 + try pch.publish(repo_opts, io, allocator, &admin, &user_repo, &target, draft_path, .{│ │1027 .id = patch_id_hex, │ │1028 .user_id = user_id, │ │1029 .repo_id = repo_id, │ ╰───────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────╮ │1031 .timestamp = 5, │ │1032 }); │ │1033 try std.testing.expectEqual(before_publish + 1, try target.core.db.rootCursor().count());│ │1026 - try pch.publish(repo_opts, io, allocator, &admin, &target, draft_path, .{ │ │1034 + try pch.publish(repo_opts, io, allocator, &admin, &user_repo, &target, draft_path, .{ │ │1035 .id = patch_id_hex, │ │1036 .user_id = user_id, │ │1037 .repo_id = repo_id, │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │1049 try std.testing.expectEqual(null, try evt.PatchRev.readById(Repo.DB, repo_opts.hash, moment, &arena, &first_patchrev_id)); │ │1050 │ │1051 _ = arena.reset(.retain_capacity); │ │1044 - const admin_moment = try evt.currentMoment(evt.admin_repo_opts, &admin); │ │1045 - const published_fork = (try evt.Fork.readById(evt.AdminDB, evt.admin_repo_opts.hash, admin_moment, &arena, &patch_id)) orelse return error.NotFound;│ │1052 + const user_moment = try evt.currentMoment(evt.user_repo_opts, &user_repo); │ │1053 + const published_fork = (try evt.Fork.readById(evt.UserDB, evt.user_repo_opts.hash, user_moment, &arena, &patch_id)) orelse return error.NotFound; │ │1054 try std.testing.expect(!published_fork.removed); │ │1055 try std.testing.expectEqual(.publish, published_fork.event.stage); │ │1048 - const draft_key = evt.Fork.draftKey(&repo_id, &user_id); │ │1049 - try std.testing.expectEqual(0, try indexedForkCount(admin_moment, evt.Fork.repo_user_to_draft_id_set_key, &draft_key)); │ │1050 - try std.testing.expectEqual(2, try indexedForkCount(admin_moment, evt.Fork.user_id_to_fork_id_set_key, &user_id)); │ │1056 + try std.testing.expectEqual(0, try draftForkCount(user_moment, &repo_id)); │ │1057 + try std.testing.expectEqual(2, try activeForkCount(user_moment)); │ │1058 var squash_oid: [hash.hexLen(repo_opts.hash)]u8 = undefined; │ │1059 { │ │1060 var draft = try Repo.open(io, allocator, .{ .path = draft_path }); │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────╮ │next →│ ╰──────╯