╭ changed ─────────╮ │src/test/event.zig│ ╰──────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │783 try std.testing.expectError(error.MergeConflict, evt.consume(repo_opts, io, allocator, &repo, .{ .kind = .head, .name = "haxy/meta" }));│ │784 } │ │785 │ │786 -test "user" { │ │786 +test "user and repo" { │ │787 const io = std.testing.io; │ │788 const allocator = std.testing.allocator; │ │789 - const temp_dir_name = "temp-event-user"; │ │789 + const temp_dir_name = "temp-event-user-and-repo"; │ │790 │ │791 // create the temp dir │ │792 const cwd = std.Io.Dir.cwd(); │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │819 │ │820 var prng = std.Random.DefaultPrng.init(std.testing.random_seed); │ │821 const user_event_id = evt.randomId(prng.random()); │ │822 + const repo_event_id = evt.randomId(prng.random()); │ │823 │ │824 var first_password_hash_buf: [usr.password_hash_max_len]u8 = undefined; │ │825 const first_password_hash = try usr.hashPassword("correct horse battery staple", &first_password_hash_buf, io);│ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────╮ │849 }, │ │850 }, │ │851 }, │ │852 + .{ │ │853 + .id = std.fmt.bytesToHex(repo_event_id, .lower),│ │854 + .data = .{ │ │855 + .repo = .{ │ │856 + .user_id = &user_event_id, │ │857 + .name = "ziglings", │ │858 + .enable_issue = true, │ │859 + }, │ │860 + }, │ │861 + }, │ │862 }; │ │863 │ │864 // │ ╰─────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────╮ │854 - // insert users as commits in the repo │ │865 + // insert users and repos as commits in the repo│ │866 // │ │867 │ │868 { │ ╰─────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │919 │ │920 // the password was correctly edited │ │921 try std.testing.expectEqualStrings(events_to_consume[1].data.user.password_hash, user.user.password_hash); │ │922 + │ │923 + // get the map of repos │ │924 + const event_id_to_repo_cursor = try haxy_moment.getCursor(hash.hashInt(repo_opts.hash, "event-id->repo")) orelse return error.NotFound;│ │925 + const event_id_to_repo = try Repo.DB.HashMap(.read_only).init(event_id_to_repo_cursor); │ │926 + │ │927 + // get the repo out of the map │ │928 + const repo_cursor = try event_id_to_repo.getCursor(hash.hashInt(repo_opts.hash, &repo_event_id)) orelse return error.NotFound; │ │929 + const repo_map = try Repo.DB.HashMap(.read_only).init(repo_cursor); │ │930 + const repo_event = try evt.EventData.read(Repo.DB, repo_opts.hash, arena.allocator(), repo_map, .repo); │ │931 + │ │932 + try std.testing.expectEqualSlices(u8, &user_event_id, repo_event.repo.user_id); │ │933 + try std.testing.expectEqualStrings("ziglings", repo_event.repo.name); │ │934 } │ │935 } │ │936 │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯