╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ event.zig ────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
744 const user_repos_cursor = try user_id_to_repos.getCursor(hash.hashInt(repo_opts.hash, &user_event_id)) orelse return error.NotFound; 745 const user_repos = try Repo.DB.CountedHashSet(.read_only).init(user_repos_cursor); 746 747 try std.testing.expectEqual(1, try user_repos.count()); 748 749 try std.testing.expect(null != try user_repos.getCursor(hash.hashInt(repo_opts.hash, &repo_event_id))); 750 } 751 752 // 753 // remove the repo 754 // 755 756 const events_to_consume2 = [_]evt.EventWithId{ 757 .{ 758 .id = std.fmt.bytesToHex(repo_event_id, .lower), 759 .event = .{ .repo = null }, 760 }, 761 }; 762 763 // commit and consume the removal 764 try evt.commitAndConsume(repo_opts, io, allocator, &repo, .{ .kind = .head, .name = "haxy/meta" }, &events_to_consume2); 765 766 { 767 const haxy_moment = try evt.currentMoment(repo_opts, &repo); 768 769 // get the map of repos 770 const event_id_to_repo_cursor = try haxy_moment.getCursor(hash.hashInt(repo_opts.hash, "event-id->repo")) orelse return error.NotFound; 771 const event_id_to_repo = try Repo.DB.HashMap(.read_only).init(event_id_to_repo_cursor); 772 773 try std.testing.expect(null == try event_id_to_repo.getCursor(hash.hashInt(repo_opts.hash, &repo_event_id))); 774 775 // get the repos created by the user 776 const user_id_to_repos_cursor = try haxy_moment.getCursor(hash.hashInt(repo_opts.hash, "user-id->repos")) orelse return error.NotFound; 777 const user_id_to_repos = try Repo.DB.HashMap(.read_only).init(user_id_to_repos_cursor); 778 779 const user_repos_cursor = try user_id_to_repos.getCursor(hash.hashInt(repo_opts.hash, &user_event_id)) orelse return error.NotFound; 780 const user_repos = try Repo.DB.CountedHashSet(.read_only).init(user_repos_cursor); 781 782 try std.testing.expectEqual(0, try user_repos.count()); 783 try std.testing.expect(null == try user_repos.getCursor(hash.hashInt(repo_opts.hash, &repo_event_id))); 784 } 785 786 // 787 // remove the user 788 // 789 790 const events_to_consume3 = [_]evt.EventWithId{ 791 .{ 792 .id = std.fmt.bytesToHex(user_event_id, .lower), 793 .event = .{ .user = null }, 794 }, 795 }; 796 797 // commit and consume the removal 798 try evt.commitAndConsume(repo_opts, io, allocator, &repo, .{ .kind = .head, .name = "haxy/meta" }, &events_to_consume3); 799 800 { 801 const haxy_moment = try evt.currentMoment(repo_opts, &repo); 802 803 // get the map of users 804 const event_id_to_user_cursor = try haxy_moment.getCursor(hash.hashInt(repo_opts.hash, "event-id->user")) orelse return error.NotFound; 805 const event_id_to_user = try Repo.DB.HashMap(.read_only).init(event_id_to_user_cursor); 806 807 try std.testing.expect(null == try event_id_to_user.getCursor(hash.hashInt(repo_opts.hash, &user_event_id))); 808 } 809 } 810