From 31f947e73dd629b1cdf18a0a28a35ef91d0e2feb Mon Sep 17 00:00:00 2001 From: Chai Bot Date: Fri, 31 Jul 2026 20:14:04 +0000 Subject: [PATCH] test: add exact-output assertion for schedule create normalization (#252) Add a full string comparison to TestReplaceVeleroWithOADP_ScheduleCreateVerbFirst that verifies cmd.Example matches the complete expected normalized text after the verb-first "velero create schedule" is rewritten to "oc oadp schedule create". The existing checks for removal of "velero create schedule" and the occurrence count of "oc oadp schedule create NAME" are kept as complementary guards. The new assertion catches any drift in whitespace, ordering, or replacement logic and shows both expected and actual strings on failure. Fixes #252 Co-Authored-By: Claude Opus 4.6 --- cmd/root_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cmd/root_test.go b/cmd/root_test.go index fe741c11b..1c6b72315 100644 --- a/cmd/root_test.go +++ b/cmd/root_test.go @@ -247,6 +247,18 @@ func TestReplaceVeleroWithOADP_ScheduleCreateVerbFirst(t *testing.T) { if wantCount != 2 { t.Errorf("Expected 2 occurrences of 'oc oadp schedule create NAME', got %d\nActual output:\n%s", wantCount, cmd.Example) } + + // Exact-output assertion: compare cmd.Example with the complete expected + // normalized string so any drift in whitespace, ordering, or replacement + // logic is caught immediately. + expected := ` # Create a backup every 6 hours. + oc oadp schedule create NAME --schedule="0 */6 * * *" + + # Create a backup every 6 hours with the @every notation. + oc oadp schedule create NAME --schedule="@every 6h"` + if cmd.Example != expected { + t.Errorf("Exact output mismatch after schedule-create normalization.\nExpected:\n%s\nActual:\n%s", expected, cmd.Example) + } } // TestReplaceVeleroWithOADP_RunFunctionWrapper tests stdout capture and replacement