From 2ecbd86e24fb25dda62283d072189f7c66338fe6 Mon Sep 17 00:00:00 2001 From: Rodin Date: Fri, 15 May 2026 04:50:21 +0000 Subject: [PATCH] =?UTF-8?q?fix(#141):=20use=20stdinValidateDocmap=20in=20C?= =?UTF-8?q?lean=20test=20=E2=80=94=20avoid=20real=20os.Stdin=20dependency?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TestRunValidateDocmap_Clean was reading real os.Stdin (fragile in CI). Switch to stdinValidateDocmap with a covered file and empty-stdin test already covered by TestRunValidateDocmap_EmptyStdin. --- cmd/review-bot/validatedocmap_test.go | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/cmd/review-bot/validatedocmap_test.go b/cmd/review-bot/validatedocmap_test.go index b19ec4f..55da6f7 100644 --- a/cmd/review-bot/validatedocmap_test.go +++ b/cmd/review-bot/validatedocmap_test.go @@ -60,19 +60,13 @@ mappings: - docs/foo.md `) - var code int - stdout, _ := captureOutput(func() { - code = runValidateDocmap([]string{ - "--docmap", docmap, - "--repo-root", dir, - }) - }) - // Provide stdin via the global os.Stdin would require process tricks. - // The implementation reads os.Stdin directly; for tests we need a different approach. - // See TestRunValidateDocmap_WithStdin_* below which use a helper that replaces os.Stdin. - // This case: empty stdin (no changed files) → clean. + // A covered file with all docs existing → clean. + code, stdout, _ := stdinValidateDocmap(t, + "lib/foo/bar.ex\n", + []string{"--docmap", docmap, "--repo-root", dir}, + ) if code != 0 { - t.Errorf("expected exit 0 for clean (empty stdin), got %d", code) + t.Errorf("expected exit 0 for clean, got %d", code) } if !strings.Contains(stdout, "OK") { t.Errorf("expected 'OK' in stdout, got %q", stdout)