Skip to content

Improve test environment for Artifacts.Tests.ps1 #540

@MariusStorhaug

Description

@MariusStorhaug

Problem

The current artifact tests in Artifacts.Tests.ps1 rely on environment variables and actual artifacts from the PSModule/GitHub repository:

$Owner = $env:GITHUB_REPOSITORY_OWNER
$Repository = $env:GITHUB_REPOSITORY_NAME
$WorkflowRunId = $env:GITHUB_RUN_ID
$ArtifactName = 'module'

This approach has several limitations:

  1. Dependency on real data: Tests depend on artifacts actually existing in the repository
  2. Brittle tests: If artifacts are deleted or workflow runs change, tests may fail
  3. Limited test scenarios: Can only test against whatever artifacts happen to exist
  4. CI/CD coupling: Tests are tightly coupled to the CI/CD pipeline state

Proposed Solution

Create a dedicated test environment for artifact tests that:

  1. Mock artifact data: Use test fixtures or mock data instead of relying on real artifacts
  2. Predictable test data: Create a controlled set of test artifacts with known properties
  3. Isolated test workflows: Consider a separate workflow that generates test artifacts specifically for testing purposes
  4. Better coverage: Enable testing edge cases and error scenarios that may not exist in production

Implementation Ideas

  • Create a dedicated test workflow that generates artifacts with predictable names and properties
  • Use mock/stub data for unit tests
  • Consider integration tests that use a sandbox repository
  • Document the test data setup in the test README

Related Files

  • tests/Artifacts.Tests.ps1 (lines 37-40)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions