fix(scripts): standardize timestamp in Test-CopyrightHeaders.ps1 to use Get-StandardTimestamp#1278
Conversation
…se Get-StandardTimestamp Replace Get-Date -Format "o" with Get-StandardTimestamp from CIHelpers.psm1 for consistent UTC ISO 8601 timestamps. Add Pester test for timestamp format. Fixes #995
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1278 +/- ##
==========================================
- Coverage 87.72% 87.71% -0.02%
==========================================
Files 61 61
Lines 9320 9320
==========================================
- Hits 8176 8175 -1
- Misses 1144 1145 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Automated Review
Overview
The production change is correct and minimal — a clean, single-expression swap from Get-Date -Format "o" to Get-StandardTimestamp, with no unintended side effects. The PR aligns directly with issue #995, the description is complete, and the template is filled in properly.
Two minor issues were found in the new Pester test; the production script itself has no concerns.
Issue Alignment ✅
Issue #995 asks to replace Get-Date -Format "o" with Get-StandardTimestamp in Test-CopyrightHeaders.ps1 and update the corresponding Pester tests. The PR does exactly this — one production line changed, one test added. No scope creep; no missing requirements.
PR Template Compliance ✅
All required sections are filled in. The checked boxes (Bug fix, Script/automation) match the actual changes. Testing and checklist sections are complete.
Coding Standards
scripts/tests/linting/Test-CopyrightHeaders.Tests.ps1 — 2 findings (inline comments attached)
-
Test name (line 601) — does not follow the
given_context_when_action_then_expectedor descriptive snake_case convention required bypester-testing.instructions.md. The current name describes the implementation mechanism rather than the observable behaviour. -
.ToString('o')call (line 603) — semantically misleading when applied to a JSON-deserialized string. The assertion should cast explicitly to[string]and match directly, avoiding reliance on implicit PowerShell version-specificDateTimecoercion inConvertFrom-Json.
Code Quality ✅
No bugs, logic errors, security concerns, or performance issues. The production change is a straightforward, safe substitution.
Action Items
- Rename the test to describe the observable outcome rather than the implementation detail (e.g.,
'Timestamp field contains a UTC ISO 8601 value ending in Z'). - Replace
$results.timestamp.ToString('o')with[string]$results.timestampto make the assertion version-independent and unambiguous.
- rename test to behavior-focused sentence matching codebase convention - replace ConvertFrom-Json assertion with raw JSON match to avoid PS7 DateTime coercion - follow established pattern from Test-ActionVersionConsistency.Tests.ps1 🔧 - Generated by Copilot
Use raw JSON string matching instead of ConvertFrom-Json with property access, avoiding PowerShell 7 DateTime coercion that makes direct regex matching unreliable. Pattern follows the established approach from Test-CopyrightHeaders.Tests.ps1 (#1278).
Pull Request
Description
Replaced
Get-Date -Format "o"(local-offset timestamp) inTest-CopyrightHeaders.ps1withGet-StandardTimestampfromCIHelpers.psm1. The script already importsCIHelpers.psm1at line 77, so no additional import was needed. This produces genuine UTC timestamps ending inZinstead of local-offset timestamps.Added a Pester test that verifies the result JSON contains a UTC ISO 8601 timestamp ending in
Z.Related Issue(s)
Fixes #995
Type of Change
Select all that apply:
Code & Documentation:
Infrastructure & Configuration:
AI Artifacts:
prompt-builderagent and addressed all feedback.github/instructions/*.instructions.md).github/prompts/*.prompt.md).github/agents/*.agent.md).github/skills/*/SKILL.md)Other:
.ps1,.sh,.py)Testing
Get-Date -Format "o"replaced withGet-StandardTimestampat line 242.timestampfield matches^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.*Z$.npm run lint:pspassed.npm run test:pspassed (45 tests for this file).Checklist
Required Checks
Required Automated Checks
The following validation commands must pass before merging:
npm run lint:mdnpm run spell-checknpm run lint:frontmatternpm run validate:skillsnpm run lint:md-linksnpm run lint:psnpm run plugin:generateSecurity Considerations
Additional Notes
This is part of the timestamp standardization series (issues #994-#1002). The prerequisite
Get-StandardTimestampfunction was merged in #993.CIHelpers.psm1was already imported by this script, so the change is a direct expression swap with no import changes required.