╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ event.zig ────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
905 }; 906 try evt.commitAndConsume(repo_opts, io, allocator, &repo, evt.events_ref, &events); 907 908 { 909 const moment = try evt.currentMoment(repo_opts, &repo); 910 try Check.order(Repo.DB, repo_opts.hash, moment, &.{ &repo_ids[0], &repo_ids[1], &repo_ids[2], &repo_ids[3] }); 911 912 // the single user shows up in its own ordered set 913 const ucur = try moment.getCursor(hash.hashInt(repo_opts.hash, "user-id-set")) orelse return error.NotFound; 914 const uset = try Repo.DB.SortedSet(.read_only).init(ucur); 915 try std.testing.expectEqual(1, try uset.count()); 916 } 917 918 // delete repo1 -> dense order (no tombstone) 919 try evt.commitAndConsume(repo_opts, io, allocator, &repo, evt.events_ref, &[_]evt.EventWithId{ 920 .{ .id = std.fmt.bytesToHex(repo_ids[1], .lower), .timestamp = 200, .event = .{ .repo = null } }, 921 }); 922 { 923 const moment = try evt.currentMoment(repo_opts, &repo); 924 try Check.order(Repo.DB, repo_opts.hash, moment, &.{ &repo_ids[0], &repo_ids[2], &repo_ids[3] }); 925 } 926 927 // update repo0 at a later timestamp -> keeps its original slot 928 try evt.commitAndConsume(repo_opts, io, allocator, &repo, evt.events_ref, &[_]evt.EventWithId{ 929 .{ .id = std.fmt.bytesToHex(repo_ids[0], .lower), .timestamp = 300, .event = .{ .repo = .{ .user_id = &user_id, .name = "repo0", .description = "updated", .enable_issue = true } } }, 930 }); 931 { 932 const moment = try evt.currentMoment(repo_opts, &repo); 933 try Check.order(Repo.DB, repo_opts.hash, moment, &.{ &repo_ids[0], &repo_ids[2], &repo_ids[3] }); 934 935 // the value really was updated 936 const e2r_cur = try moment.getCursor(hash.hashInt(repo_opts.hash, "event-id->repo")) orelse return error.NotFound; 937 const e2r = try Repo.DB.HashMap(.read_only).init(e2r_cur); 938 const rc = try e2r.getCursor(hash.hashInt(repo_opts.hash, &repo_ids[0])) orelse return error.NotFound; 939 const rm = try Repo.DB.HashMap(.read_only).init(rc); 940 const re = try evt.read(evt.Repo, Repo.DB, repo_opts.hash, &arena, rm); 941 try std.testing.expectEqualStrings("updated", re.description); 942 } 943 } 944