Skip to content

test: Introduce lockfile to all Scenario tests#238

Open
Tonisal-byte wants to merge 2 commits into
microsoft:mainfrom
Tonisal-byte:asalinas/test-end-lock-helpers
Open

test: Introduce lockfile to all Scenario tests#238
Tonisal-byte wants to merge 2 commits into
microsoft:mainfrom
Tonisal-byte:asalinas/test-end-lock-helpers

Conversation

@Tonisal-byte

Copy link
Copy Markdown
Contributor

This pull request refactors how lock files are created and managed in scenario and unit tests, improving test readability and consistency. It introduces helper functions to simplify lock file creation, updates documentation to reflect these changes, and replaces manual lock file writing with the new helpers throughout the test suite.

Test infrastructure improvements:

  • Added writeLockInDir helper in scenario/component_changed_test.go to simplify writing lock files in scenario tests, replacing manual file creation with a single function call.
  • Introduced localComponentLock helper in scenario/component_render_test.go for consistent lock file creation in component render tests.
  • Updated dynamicTestProject in projecttest/dynamictestproject.go to maintain a map of lock files, enabling programmatic lock file management and serialization. [1] [2]

Copilot AI review requested due to automatic review settings June 10, 2026 23:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds first-class lockfile support to scenario dynamic test projects, allowing tests to generate and update component lockfiles via helpers instead of handwritten TOML strings.

Changes:

  • Introduces projecttest.AddLock(...) (serialize-time) and projecttest.WriteLock(...) (post-serialize updates) utilities for scenario fixtures.
  • Extends dynamicTestProject to track and serialize component lockfiles (including when initializing a git repo).
  • Updates scenario tests and testing guidance to use the new lock helpers.

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
scenario/testdata/simple/locks/a.lock Adds a basic lockfile fixture used by simple scenario testdata.
scenario/internal/projecttest/lockfile_test.go Adds unit tests validating lock serialization, updating, and conflict handling.
scenario/internal/projecttest/lockfile.go Adds lockfile option helpers and filesystem writing helpers for scenario projects.
scenario/internal/projecttest/dynamictestproject.go Adds lock tracking/serialization to dynamic test projects and prevents AddFile/AddLock path conflicts.
scenario/component_render_test.go Switches render scenario fixtures from raw lockfile strings to AddLock.
scenario/component_query_test.go Adds a lockfile to the query scenario fixture via AddLock.
scenario/component_changed_test.go Replaces ad-hoc lockfile string writes with projecttest.WriteLock helper.
scenario/component_build_test.go Adds a lockfile to the build scenario fixture via AddLock.
.github/instructions/testing.instructions.md Documents how to create lock files in unit tests vs scenario fixtures.

Comment thread scenario/internal/projecttest/dynamictestproject.go Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants