╭ changed ─────────╮ │src/test/event.zig│ ╰──────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭──────────────────────────────────────────────────╮ │ 5 const rp = xit.repo; │ │ 6 const hash = xit.hash; │ │ 7 │ │ 8 -test "simple" { │ │ 8 +test "rebase" { │ │ 9 const io = std.testing.io; │ │10 const allocator = std.testing.allocator; │ │11 - const temp_dir_name = "temp-event-simple";│ │11 + const temp_dir_name = "temp-event-rebase";│ │12 │ │13 // create the temp dir │ │14 const cwd = std.Io.Dir.cwd(); │ ╰──────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │185 // read the moment we just created │ │186 const moment_cursor = try history.getCursor(-1) orelse return error.NotFound; │ │187 const moment = try Repo.DB.HashMap(.read_only).init(moment_cursor); │ │188 + │ │189 + // get the last object id │ │190 + const last_object_id_cursor = try moment.getCursor(hash.hashInt(repo_opts.hash, "haxy-last-object-id")) orelse return error.NotFound;│ │191 + var last_object_id: [hash.byteLen(repo_opts.hash)]u8 = undefined; │ │192 + _ = try last_object_id_cursor.readBytes(&last_object_id); │ │193 │ │194 const haxy_cursor = try moment.getCursor(hash.hashInt(repo_opts.hash, "haxy")) orelse return error.NotFound; │ │190 - const haxy = try Repo.DB.HashMap(.read_only).init(haxy_cursor); │ │195 + const haxy = try Repo.DB.ArrayList(.read_only).init(haxy_cursor); │ │196 + │ │197 + try std.testing.expectEqual(1, try haxy.count()); │ │198 │ │192 - const object_id_to_views_cursor = try haxy.getCursor(hash.hashInt(repo_opts.hash, "object-id->views")) orelse return error.NotFound; │ │193 - const object_id_to_views = try Repo.DB.HashMap(.read_only).init(object_id_to_views_cursor); │ │199 + const haxy_moments_cursor = try haxy.getCursor(-1) orelse return error.NotFound; │ │200 + const haxy_moments = try Repo.DB.HashMap(.read_only).init(haxy_moments_cursor); │ │201 │ │195 - // get the last object id │ │196 - const last_object_id_cursor = try haxy.getCursor(hash.hashInt(repo_opts.hash, "last-object-id")) orelse return error.NotFound; │ │197 - var last_object_id: [hash.byteLen(repo_opts.hash)]u8 = undefined; │ │198 - _ = try last_object_id_cursor.readBytes(&last_object_id); │ │202 + const haxy_moment_cursor = try haxy_moments.getCursor(hash.bytesToInt(repo_opts.hash, &last_object_id)) orelse return error.NotFound;│ │203 + const haxy_moment = try Repo.DB.HashMap(.read_only).init(haxy_moment_cursor); │ │204 │ │200 - // get the latest views (the views generated by the last object id) │ │201 - const views_cursor = try object_id_to_views.getCursor(hash.bytesToInt(repo_opts.hash, &last_object_id)) orelse return error.NotFound;│ │205 + // get the views │ │206 + const views_cursor = try haxy_moment.getCursor(hash.hashInt(repo_opts.hash, "views")) orelse return error.NotFound; │ │207 const views = try Repo.DB.HashMap(.read_only).init(views_cursor); │ │208 │ │209 // get the map of issues │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │292 // read the moment we just created │ │293 const moment_cursor = try history.getCursor(-1) orelse return error.NotFound; │ │294 const moment = try Repo.DB.HashMap(.read_only).init(moment_cursor); │ │295 + │ │296 + // get the last object id │ │297 + const last_object_id_cursor = try moment.getCursor(hash.hashInt(repo_opts.hash, "haxy-last-object-id")) orelse return error.NotFound;│ │298 + var last_object_id: [hash.byteLen(repo_opts.hash)]u8 = undefined; │ │299 + _ = try last_object_id_cursor.readBytes(&last_object_id); │ │300 │ │301 const haxy_cursor = try moment.getCursor(hash.hashInt(repo_opts.hash, "haxy")) orelse return error.NotFound; │ │292 - const haxy = try Repo.DB.HashMap(.read_only).init(haxy_cursor); │ │302 + const haxy = try Repo.DB.ArrayList(.read_only).init(haxy_cursor); │ │303 + │ │304 + try std.testing.expectEqual(2, try haxy.count()); │ │305 │ │294 - const object_id_to_views_cursor = try haxy.getCursor(hash.hashInt(repo_opts.hash, "object-id->views")) orelse return error.NotFound; │ │295 - const object_id_to_views = try Repo.DB.HashMap(.read_only).init(object_id_to_views_cursor); │ │306 + const haxy_moments_cursor = try haxy.getCursor(-1) orelse return error.NotFound; │ │307 + const haxy_moments = try Repo.DB.HashMap(.read_only).init(haxy_moments_cursor); │ │308 │ │297 - // get the last object id │ │298 - const last_object_id_cursor = try haxy.getCursor(hash.hashInt(repo_opts.hash, "last-object-id")) orelse return error.NotFound; │ │299 - var last_object_id: [hash.byteLen(repo_opts.hash)]u8 = undefined; │ │300 - _ = try last_object_id_cursor.readBytes(&last_object_id); │ │309 + const haxy_moment_cursor = try haxy_moments.getCursor(hash.bytesToInt(repo_opts.hash, &last_object_id)) orelse return error.NotFound;│ │310 + const haxy_moment = try Repo.DB.HashMap(.read_only).init(haxy_moment_cursor); │ │311 │ │302 - // get the latest views (the views generated by the last object id) │ │303 - const views_cursor = try object_id_to_views.getCursor(hash.bytesToInt(repo_opts.hash, &last_object_id)) orelse return error.NotFound;│ │312 + // get the views │ │313 + const views_cursor = try haxy_moment.getCursor(hash.hashInt(repo_opts.hash, "views")) orelse return error.NotFound; │ │314 const views = try Repo.DB.HashMap(.read_only).init(views_cursor); │ │315 │ │316 // get the map of issues │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │394 // read the moment we just created │ │395 const moment_cursor = try history.getCursor(-1) orelse return error.NotFound; │ │396 const moment = try Repo.DB.HashMap(.read_only).init(moment_cursor); │ │387 - │ │388 - const haxy_cursor = try moment.getCursor(hash.hashInt(repo_opts.hash, "haxy")) orelse return error.NotFound; │ │389 - const haxy = try Repo.DB.HashMap(.read_only).init(haxy_cursor); │ │390 - │ │391 - const object_id_to_views_cursor = try haxy.getCursor(hash.hashInt(repo_opts.hash, "object-id->views")) orelse return error.NotFound; │ │392 - const object_id_to_views = try Repo.DB.HashMap(.read_only).init(object_id_to_views_cursor); │ │397 │ │398 // get the last object id │ │395 - const last_object_id_cursor = try haxy.getCursor(hash.hashInt(repo_opts.hash, "last-object-id")) orelse return error.NotFound; │ │399 + const last_object_id_cursor = try moment.getCursor(hash.hashInt(repo_opts.hash, "haxy-last-object-id")) orelse return error.NotFound;│ │400 var last_object_id: [hash.byteLen(repo_opts.hash)]u8 = undefined; │ │401 _ = try last_object_id_cursor.readBytes(&last_object_id); │ │402 │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │399 - // get the latest views (the views generated by the last object id) │ │400 - const views_cursor = try object_id_to_views.getCursor(hash.bytesToInt(repo_opts.hash, &last_object_id)) orelse return error.NotFound;│ │403 + const haxy_cursor = try moment.getCursor(hash.hashInt(repo_opts.hash, "haxy")) orelse return error.NotFound; │ │404 + const haxy = try Repo.DB.ArrayList(.read_only).init(haxy_cursor); │ │405 + │ │406 + try std.testing.expectEqual(1, try haxy.count()); │ │407 + │ │408 + const haxy_moments_cursor = try haxy.getCursor(-1) orelse return error.NotFound; │ │409 + const haxy_moments = try Repo.DB.HashMap(.read_only).init(haxy_moments_cursor); │ │410 + │ │411 + const haxy_moment_cursor = try haxy_moments.getCursor(hash.bytesToInt(repo_opts.hash, &last_object_id)) orelse return error.NotFound;│ │412 + const haxy_moment = try Repo.DB.HashMap(.read_only).init(haxy_moment_cursor); │ │413 + │ │414 + // get the views │ │415 + const views_cursor = try haxy_moment.getCursor(hash.hashInt(repo_opts.hash, "views")) orelse return error.NotFound; │ │416 const views = try Repo.DB.HashMap(.read_only).init(views_cursor); │ │417 │ │418 // get the map of issues │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯