Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TR-1: Implement Unit Testing: Convert-HawkDaysToDate.Tests.ps1 #251

Open
jonnybottles opened this issue Jan 26, 2025 · 0 comments
Open

TR-1: Implement Unit Testing: Convert-HawkDaysToDate.Tests.ps1 #251

jonnybottles opened this issue Jan 26, 2025 · 0 comments
Assignees
Labels
status/backlog In backlog / validated type/feature New feature or request type/gaant Used for Gaant Visualization

Comments

@jonnybottles
Copy link
Collaborator

jonnybottles commented Jan 26, 2025

Description:
The Convert-HawkDaysToDate function is a critical internal helper function in the Hawk module that converts a "days to look back" value into proper UTC StartDate and EndDate values for investigation timeframes. This function ensures consistent date handling across the module and validates that the specified date range doesn't exceed 365 days.

Requirements:

  • Create a new Pester test file named Convert-HawkDaysToDate.Tests.ps1.
  • Place the file in: Hawk/tests/functions/.
  • Follow the existing test pattern from other function tests in the module.

Test Cases Should Cover:

  • Valid input scenarios:

    • Standard days lookback (e.g., 30 days)
    • Minimum value (1 day)
    • Maximum value (365 days)
  • Output validation:

    • Verify StartDate is the correct number of days in the past.
    • Verify EndDate is set to midnight of the next day (UTC).
    • Verify both dates are in UTC format.
    • Verify date object types are correct.

Test Execution:
Your tests will be automatically discovered and executed by the module's test runner in Hawk/tests/pester.ps1. This script is called during module validation through vsts-validate.ps1.

To manually run your tests during development:

# From the Hawk root directory:
./tests/pester.ps1 -TestFunctions $true
@jonnybottles jonnybottles added status/backlog In backlog / validated type/feature New feature or request type/gaant Used for Gaant Visualization labels Jan 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/backlog In backlog / validated type/feature New feature or request type/gaant Used for Gaant Visualization
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants