@@ -3,6 +3,9 @@ import { mkdirSync, mkdtempSync, writeFileSync } from "node:fs";
33import { tmpdir } from "node:os" ;
44import { join } from "node:path" ;
55
6+ import { registerPinDriftTool } from "./pin-drift-tool.js" ;
7+ import { captureTool } from "./test-harness.js" ;
8+
69// ---------------------------------------------------------------------------
710// Helpers: create fixture repos in temp dirs (kept for potential future use)
811// ---------------------------------------------------------------------------
@@ -268,3 +271,34 @@ describe("parseVersionsEnv", () => {
268271 expect ( skipped . length ) . toBe ( 2 ) ;
269272 } ) ;
270273} ) ;
274+
275+ // ---------------------------------------------------------------------------
276+ // pin_drift tool integration (via captureTool)
277+ //
278+ // An empty directory has no go.mod / .gitmodules / package.json, so the tool
279+ // collects zero pins and returns immediately — no GitHub API call is made.
280+ //
281+ // Requires GitHub auth to pass the initial gateAuth check.
282+ // ---------------------------------------------------------------------------
283+
284+ describe ( "pin_drift tool (captureTool)" , ( ) => {
285+ test ( "empty directory → 0 pins, JSON format" , async ( ) => {
286+ const dir = mkdtempSync ( join ( tmpdir ( ) , "pin-drift-tool-test-" ) ) ;
287+ const run = captureTool ( registerPinDriftTool ) ;
288+ const text = await run ( { localPath : dir , format : "json" } ) ;
289+ const parsed = JSON . parse ( text ) as { summary ?: { totalPins : number } } ;
290+ // If auth unavailable, summary is absent — skip gracefully
291+ if ( ! parsed . summary ) return ;
292+ expect ( parsed . summary . totalPins ) . toBe ( 0 ) ;
293+ expect ( parsed . summary . stale ) . toBe ( 0 ) ;
294+ } ) ;
295+
296+ test ( "empty directory → markdown shows 0 pins" , async ( ) => {
297+ const dir = mkdtempSync ( join ( tmpdir ( ) , "pin-drift-tool-test-" ) ) ;
298+ const run = captureTool ( registerPinDriftTool ) ;
299+ const text = await run ( { localPath : dir } ) ;
300+ // Auth error returns JSON; markdown path contains the pin count header
301+ if ( text . startsWith ( "{" ) ) return ;
302+ expect ( text ) . toContain ( "0 pins" ) ;
303+ } ) ;
304+ } ) ;
0 commit comments