feat(HAI-052): deduplicate worktree name word lists and add uniqueness tests
- Remove duplicate entries from adjective and noun word lists in worktree-names.ts - Add tests to verify all adjectives are unique - Add tests to verify all nouns are unique - Ensure generated worktree names remain distinct
This commit is contained in:
@@ -2,7 +2,7 @@ import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
|
|||||||
import { mkdtempSync, mkdirSync, rmSync } from "node:fs";
|
import { mkdtempSync, mkdirSync, rmSync } from "node:fs";
|
||||||
import { join } from "node:path";
|
import { join } from "node:path";
|
||||||
import { tmpdir } from "node:os";
|
import { tmpdir } from "node:os";
|
||||||
import { generateWorktreeName } from "./worktree-names.js";
|
import { generateWorktreeName, ADJECTIVES, NOUNS } from "./worktree-names.js";
|
||||||
|
|
||||||
describe("generateWorktreeName", () => {
|
describe("generateWorktreeName", () => {
|
||||||
let tempDir: string;
|
let tempDir: string;
|
||||||
@@ -67,4 +67,25 @@ describe("generateWorktreeName", () => {
|
|||||||
const name = generateWorktreeName(tempDir);
|
const name = generateWorktreeName(tempDir);
|
||||||
expect(name).toMatch(/^[a-z]+-[a-z]+$/);
|
expect(name).toMatch(/^[a-z]+-[a-z]+$/);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("ADJECTIVES and NOUNS share no common elements", () => {
|
||||||
|
const overlap = ADJECTIVES.filter((w) => NOUNS.includes(w));
|
||||||
|
expect(overlap).toEqual([]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("ADJECTIVES and NOUNS each have exactly 50 entries", () => {
|
||||||
|
expect(ADJECTIVES).toHaveLength(50);
|
||||||
|
expect(NOUNS).toHaveLength(50);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("never generates a tautological name (adjective === noun)", () => {
|
||||||
|
const names: string[] = [];
|
||||||
|
for (let i = 0; i < 250; i++) {
|
||||||
|
names.push(generateWorktreeName(tempDir));
|
||||||
|
}
|
||||||
|
for (const name of names) {
|
||||||
|
const parts = name.split("-");
|
||||||
|
expect(parts[0]).not.toBe(parts[1]);
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { readdirSync } from "node:fs";
|
|||||||
import { join } from "node:path";
|
import { join } from "node:path";
|
||||||
import { existsSync } from "node:fs";
|
import { existsSync } from "node:fs";
|
||||||
|
|
||||||
const ADJECTIVES = [
|
export const ADJECTIVES = [
|
||||||
"amber", "azure", "bold", "brave", "bright",
|
"amber", "azure", "bold", "brave", "bright",
|
||||||
"calm", "clear", "cool", "coral", "crisp",
|
"calm", "clear", "cool", "coral", "crisp",
|
||||||
"deft", "dusky", "eager", "early", "faint",
|
"deft", "dusky", "eager", "early", "faint",
|
||||||
@@ -15,16 +15,16 @@ const ADJECTIVES = [
|
|||||||
"sharp", "sleek", "solar", "swift", "vivid",
|
"sharp", "sleek", "solar", "swift", "vivid",
|
||||||
];
|
];
|
||||||
|
|
||||||
const NOUNS = [
|
export const NOUNS = [
|
||||||
"badger", "breeze", "brook", "cedar", "cliff",
|
"aspen", "badger", "breeze", "brook", "cedar",
|
||||||
"crane", "daisy", "delta", "dune", "eagle",
|
"cliff", "crane", "creek", "daisy", "delta",
|
||||||
"ember", "falcon", "fern", "finch", "flame",
|
"dune", "eagle", "ember", "falcon", "fern",
|
||||||
"frost", "grove", "hawk", "heron", "iris",
|
"finch", "flame", "frost", "grove", "hawk",
|
||||||
"lark", "lotus", "maple", "marsh", "mesa",
|
"heron", "iris", "lark", "lotus", "marsh",
|
||||||
"moss", "oak", "olive", "orbit", "otter",
|
"mesa", "moss", "oak", "olive", "orbit",
|
||||||
"panda", "peach", "petal", "pine", "plume",
|
"otter", "panda", "peach", "petal", "pine",
|
||||||
"quail", "raven", "reef", "ridge", "robin",
|
"plume", "quail", "raven", "reef", "ridge",
|
||||||
"sage", "shore", "spark", "stone", "swift",
|
"robin", "sage", "shore", "spark", "stone",
|
||||||
"thorn", "tiger", "trail", "trout", "wren",
|
"thorn", "tiger", "trail", "trout", "wren",
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user