╭ changed ─────────╮ │src/test/event.zig│ ╰──────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │565 // check out the haxy/meta branch and merge the haxy/other branch into it │ │566 // │ │567 │ │568 - { │ │568 + const merge_oid = blk: { │ │569 var result = try repo.switchDir(io, allocator, .{ .target = .{ .ref = .{ .kind = .head, .name = "haxy/meta" } } });│ │570 defer result.deinit(); │ │571 │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────╮ │573 defer merge.deinit(); │ │574 │ │575 try std.testing.expect(.success == merge.result);│ │576 - } │ │576 │ │577 + break :blk merge.result.success.oid; │ │578 + }; │ │579 + │ │580 // │ │581 // consume events into the database │ │582 // │ ╰──────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │705 try std.testing.expect(null == first_issue_cursor); │ │706 } │ │707 } │ │708 + │ │709 + // │ │710 + // define test events that modify the same issue in conflicting ways │ │711 + // │ │712 + │ │713 + const events_to_consume3 = [_]evt.Event{ │ │714 + .{ │ │715 + .id = events_to_consume[0].id, │ │716 + .data = .{ │ │717 + .issue = .{ │ │718 + .title = "Login form clears password on validation error", │ │719 + .description = "Submitting an invalid email address resets the password field. Preserve the field value and show an inline validation message.", │ │720 + .tags = "bug\x00priority-low\x00ui", │ │721 + }, │ │722 + }, │ │723 + }, │ │724 + .{ │ │725 + .id = events_to_consume[0].id, │ │726 + .data = .{ │ │727 + .issue = .{ │ │728 + .title = "Login form clears password on validation error", │ │729 + .description = "Submitting an invalid email address resets the password field. Preserve the field value and show an inline validation message.", │ │730 + .tags = "bug\x00priority-medium\x00ui", │ │731 + }, │ │732 + }, │ │733 + }, │ │734 + }; │ │735 + │ │736 + // │ │737 + // insert issues as commits in the repo on different branches │ │738 + // │ │739 + │ │740 + { │ │741 + var json: std.Io.Writer.Allocating = .init(std.testing.allocator); │ │742 + defer json.deinit(); │ │743 + │ │744 + for (events_to_consume3, 0..) |event, i| { │ │745 + json.clearRetainingCapacity(); │ │746 + │ │747 + try std.json.Stringify.value(event, .{}, &json.writer); │ │748 + │ │749 + // commit the event into a special branch │ │750 + _ = try repo.commitAtRef( │ │751 + io, │ │752 + allocator, │ │753 + .{ .parent_oids = &.{merge_oid}, .message = json.written() }, │ │754 + null, │ │755 + .{ .kind = .head, .name = switch (i) { │ │756 + 0 => "haxy/meta", │ │757 + 1 => "haxy/other", │ │758 + else => unreachable, │ │759 + } }, │ │760 + ); │ │761 + } │ │762 + } │ │763 + │ │764 + // │ │765 + // check out the haxy/meta branch and merge the haxy/other branch into it │ │766 + // │ │767 + │ │768 + { │ │769 + var result = try repo.switchDir(io, allocator, .{ .target = .{ .ref = .{ .kind = .head, .name = "haxy/meta" } } }); │ │770 + defer result.deinit(); │ │771 + │ │772 + var merge = try repo.merge(io, allocator, .{ .kind = .full, .action = .{ .new = .{ .source = &.{.{ .ref = .{ .kind = .head, .name = "haxy/other" } }} } } }, null);│ │773 + defer merge.deinit(); │ │774 + │ │775 + try std.testing.expect(.success == merge.result); │ │776 + } │ │777 + │ │778 + // │ │779 + // consume events into the database │ │780 + // │ │781 + │ │782 + try std.testing.expectError(error.MergeConflict, evt.consume(repo_opts, io, allocator, &repo, .{ .kind = .head, .name = "haxy/meta" })); │ │783 } │ │784 │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯