Skip to content

Add black-box E2E tests for create command#46

Merged
josecelano merged 4 commits into
mainfrom
copilot/add-e2e-black-box-test
Oct 26, 2025
Merged

Add black-box E2E tests for create command#46
josecelano merged 4 commits into
mainfrom
copilot/add-e2e-black-box-test

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Oct 26, 2025

Implements true black-box E2E testing for the create command by running the production binary as an external process, exercising the complete workflow from config file to persisted state.

Test Infrastructure (tests/support/)

  • TempWorkspace: Temporary directory management with automatic cleanup
  • ProcessRunner: Executes cargo run with proper arg handling and --working-dir support
  • EnvironmentStateAssertions: Validates persisted JSON state and directory structure

Test Coverage (tests/e2e_create_command.rs)

  • Valid config → successful environment creation + persistence verification
  • Invalid config → graceful failure with validation errors
  • Missing config file → appropriate file not found error
  • Duplicate environment → already exists error

Example Usage

let workspace = TempWorkspace::new()?;
workspace.write_config_file("env.json", &config)?;

let result = ProcessRunner::new()
    .working_dir(workspace.path())
    .run_create_command("./env.json")?;

assert!(result.success());

let assertions = EnvironmentStateAssertions::new(workspace.path());
assertions.assert_environment_exists("test-env");
assertions.assert_environment_state_is("test-env", "Created");

Unlike existing E2E tests that mock infrastructure components, these tests validate the actual CLI interface and state persistence that users experience. Pattern is reusable for other commands (provision, configure, destroy).

Original prompt

This section details on the original issue you should resolve

<issue_title>[Subissue 4/7] E2E Black Box Test for Create Command</issue_title>
<issue_description>Parent Epic: #34 - Implement Create Environment Command
Depends On: #37 - CLI Presentation Layer
Estimated Time: 3-4 hours

Overview

Implement a true black-box end-to-end test for the create command that tests the production application as an external process. Unlike other E2E tests that mock parts of the system, this test exercises the complete application workflow from configuration file to persisted environment state.

Goals

  • Create a true black-box E2E test that runs the production application as an external process
  • Test the complete workflow: config file → command execution → environment persistence
  • Use temporary directories for complete test isolation
  • Verify environment state is correctly persisted in the data folder
  • Add support for --working-dir optional argument to specify application working directory
  • Establish pattern for black-box testing that can be extended to other commands

Architecture Requirements

Test Type: Black Box E2E Test
Test Location: tests/e2e_create_command.rs (separate from existing E2E infrastructure)
Pattern: External Process Testing + Temporary Directory Isolation

Test Structure

tests/
├── e2e_create_command.rs     # New black-box E2E test
└── support/                  # Test support utilities
    ├── temp_workspace.rs     # Temporary workspace management
    ├── process_runner.rs     # External process execution
    └── assertions.rs         # Environment state assertions

Key Test Scenarios

  1. Happy Path: Create environment from valid config file with --working-dir
  2. Invalid Config: Graceful failure with validation errors
  3. Missing Config File: Appropriate error when file not found
  4. Duplicate Detection: Error when environment already exists
  5. State Persistence: Verify complete environment state saved correctly

Acceptance Criteria

  • Black-box test runs production binary as external process
  • Test uses TempDir for complete isolation (no ./data or ./build interference)
  • Test passes --working-dir to application to specify temporary workspace
  • All assertions check persisted state in the data directory
  • Test validates error messages are user-friendly and actionable
  • Test cleans up temporary directories automatically
  • Pattern is reusable for other command E2E tests

Implementation Notes

  • Use std::process::Command to run the production binary
  • Create TempWorkspace helper for managing temporary directories
  • Build configuration files in temp workspace before running command
  • Verify environment state by reading persisted JSON files
  • Follow patterns from existing E2E tests for consistency

For detailed specification, see: docs/issues/epic-create-environment-command-subissue-4-e2e-black-box-test.md</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits October 26, 2025 07:02
Co-authored-by: josecelano <58816+josecelano@users.noreply.github.com>
Co-authored-by: josecelano <58816+josecelano@users.noreply.github.com>
Co-authored-by: josecelano <58816+josecelano@users.noreply.github.com>
Copilot AI changed the title [WIP] Add end-to-end black box test for create command Add black-box E2E tests for create command Oct 26, 2025
Copilot AI requested a review from josecelano October 26, 2025 07:17
@josecelano josecelano marked this pull request as ready for review October 26, 2025 08:45
Copy link
Copy Markdown
Member

@josecelano josecelano left a comment

Choose a reason for hiding this comment

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

ACK 8b38ce0

@josecelano josecelano merged commit 4ef803c into main Oct 26, 2025
43 checks passed
@josecelano josecelano deleted the copilot/add-e2e-black-box-test branch April 15, 2026 16:37
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.

[Subissue 4/7] E2E Black Box Test for Create Command

2 participants