214 lines · 9.0 KB
import { describe, expect, test } from "bun:test";
import { mergeText } from "../git/merge3";
import type { MergeConflict } from "../git/merge";
import { assembleResolution, blockContext } from "./candidates";
import { DEFAULT_THRESHOLDS, decideFile, floorRisk } from "./decide";
import type { ClefRequest, ClefResponse } from "./decide";
import { mockProvider } from "./mock";
import { DEFAULT_LIMITS, planMergeFix } from "./plan";
import type { FixPlan, MergeFixProvider } from "./plan";
import { belowThreshold, shouldAutoApply } from "./proposal";
import { bracketsBalanced, candidateProblem } from "./validate";

const preamble = `// Package catalog lists the storefront's products.
package catalog

import "sort"

type Product struct {
\tID    string
\tName  string
\tPrice int
}

var products = []Product{
`;
const tail = `}

func All() []Product {
\tsorted := append([]Product(nil), products...)
\tsort.Slice(sorted, func(i, j int) bool { return sorted[i].ID < sorted[j].ID })
\treturn sorted
}
`;
const row = (id: string, price: number) => `\t{ID: "${id}", Name: "${id}", Price: ${price}},\n`;
const earlier = ["beanie", "scarf", "gloves", "tote"].map((id, index) => row(id, 1000 + index)).join("");
const base = preamble + row("tee", 2000) + row("hoodie", 5000) + earlier + row("mug", 1200) + tail;
const main =
  preamble + row("tee", 2000) + row("hoodie", 5000) + row("giftcard", 2500) + earlier + row("mug", 1200) + tail;
const head = preamble + row("tee", 2000) + row("hoodie", 5000) + row("socks", 900) + earlier + row("mug", 1200) + tail;
const path = "internal/catalog/catalog.go";