import { describe, expect, it } from "vitest"; import { parseGoBuildTags } from "./go-build-tags.ts"; describe("parseGoBuildTags", () => { it.each([["contract,e2e"], ["contract,e2e_v2,go1.22"]])( "normalizes valid comma-separated Go build tags: %j", (tags: string) => { expect(parseGoBuildTags(tags)).toBe(tags); }, ); it("treats undefined and empty input as no build tags", () => { expect(parseGoBuildTags()).toBeUndefined(); expect(parseGoBuildTags("")).toBeUndefined(); }); it.each(["contract e2e", "contract, e2e"])( "rejects tags containing spaces: %j", (tags: string) => { expect(() => parseGoBuildTags(tags)).toThrow(); }, ); it.each([ "contract;e2e", "contract|e2e", "contract&e2e", "contract$(e2e)", "`contract`", ])("rejects shell metacharacters: %j", (tags: string) => { expect(() => parseGoBuildTags(tags)).toThrow(); }); it.each(["contract,,e2e", ",contract", "contract,"])( "rejects empty tag segments: %j", (tags: string) => { expect(() => parseGoBuildTags(tags)).toThrow(); }, ); });