Skip to content

Fix Swift Tests - Replace broken tests with comprehensive test suite#22

Closed
Copilot wants to merge 5 commits intomainfrom
copilot/fix-swift-tests
Closed

Fix Swift Tests - Replace broken tests with comprehensive test suite#22
Copilot wants to merge 5 commits intomainfrom
copilot/fix-swift-tests

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Oct 22, 2025

  • Remove all existing test files
  • Create comprehensive parsing tests for DockerCompose YAML files (37 tests)
  • Create tests for ComposeUp command with all flag combinations (60 tests)
  • Create tests for ComposeDown command with all flag combinations (58 tests)
  • Add comprehensive test documentation
  • Verify tests are syntactically correct (155 total tests)
  • Add functionality tests for ComposeUp and ComposeDown effectiveness
  • Fix import statements for proper compilation

Summary

Successfully replaced all existing tests with 155 comprehensive tests covering:

DockerComposeParsingTests.swift (37 tests)

  • Basic parsing (minimal compose, version, project name, multiple services)
  • Service configuration (image, build, environment, ports, volumes, dependencies)
  • Commands and entrypoints (array and string formats)
  • Container settings (name, hostname, user, working_dir, restart)
  • Boolean flags (privileged, read_only, stdin_open, tty)
  • Platform specification
  • Top-level resources (volumes, networks)
  • Complex integration scenarios
  • Topological sorting validation

ComposeUpTests.swift (60 tests)

Functionality Tests (11 tests)

  • Reads and parses compose files from filesystem
  • Handles missing compose file errors
  • Respects service filtering (selective startup)
  • Processes environment variables correctly
  • Processes volumes configuration
  • Processes networks configuration
  • Handles service dependencies with topological sorting
  • Determines project name correctly
  • Handles build configuration
  • Processes port mappings
  • Handles container configuration options

Argument Parsing Tests (49 tests)

  • All flags: -d/--detach, -f/--file, -b/--build, --no-cache
  • Service selection (single, multiple, none)
  • All flag combinations and permutations
  • Short and long form flags
  • File path variations
  • Real-world scenarios (production, development, testing, CI/CD)
  • Default values validation
  • Edge cases

ComposeDownTests.swift (58 tests)

Functionality Tests (9 tests)

  • Reads and parses compose files from filesystem
  • Handles missing compose file errors
  • Identifies all services to stop
  • Respects service filtering for selective shutdown
  • Handles services with dependencies (reverse order for shutdown)
  • Determines project name for container identification
  • Processes all services when no filter specified
  • Handles container naming conventions (explicit vs generated)
  • Verifies complete compose file structure

Argument Parsing Tests (49 tests)

  • File flag: -f/--file (short and long)
  • Service selection (stop all vs selective)
  • All flag combinations and permutations
  • Short and long form flags
  • File path variations
  • Service name variations (hyphenated, underscored, numeric)
  • Real-world scenarios (production, development, testing, CI/CD)
  • Default values validation
  • Edge cases

Latest Fix

Fixed import statements: Changed @testable import Yams to regular import Yams in all test files since Yams is a public API and doesn't require testable access. This resolves potential compilation issues.

Note: Tests require macOS to run due to platform-specific dependencies in ContainerComposeCore. Tests are syntactically correct and ready for execution on macOS.

Original prompt

This section details on the original issue you should resolve

<issue_title>Fix Swift Tests</issue_title>
<issue_description>I made a huge mistake when initially merging in the tests because copilot messed up and the tests mean nothing.

Lets fix it!</issue_description>

<agent_instructions>Remove all tests and then write tests for the following testing ContainerComposeCore

  • Parsing
  • ComposeUp
  • ComposeDown

Test every kind of flag in different configurations.</agent_instructions>

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

Fixes #21


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits October 22, 2025 19:13
…Up, and ComposeDown

Co-authored-by: Mcrich23 <81453549+Mcrich23@users.noreply.github.com>
Co-authored-by: Mcrich23 <81453549+Mcrich23@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix Swift tests to ensure accurate coverage Fix Swift Tests - Replace broken tests with comprehensive test suite Oct 22, 2025
Copilot AI requested a review from Mcrich23 October 22, 2025 19:18
@Mcrich23
Copy link
Copy Markdown
Owner

@copilot Good job testing parsing! But I need you to test the effectiveness and results of ComposeUp and ComposeDown.

…nd results

Co-authored-by: Mcrich23 <81453549+Mcrich23@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Oct 22, 2025

@copilot Good job testing parsing! But I need you to test the effectiveness and results of ComposeUp and ComposeDown.

Added 20 new functionality tests that verify the effectiveness and results of ComposeUp and ComposeDown commands:

ComposeUp (11 new tests):

  • File reading/parsing from filesystem
  • Service filtering for selective startup
  • Environment variable processing
  • Volumes and networks configuration
  • Service dependency handling with topological sorting
  • Project name determination
  • Build configuration processing
  • Port mappings and container options

ComposeDown (9 new tests):

  • File reading/parsing from filesystem
  • Service identification for shutdown
  • Selective vs stop-all behavior
  • Dependency handling in reverse order
  • Project name and container naming conventions
  • Complete compose file structure validation

These tests use temporary directories with actual YAML files to verify the commands parse, process, and prepare data correctly for container operations. See commit f7e7e68.

@Mcrich23
Copy link
Copy Markdown
Owner

@copilot fix the compiler errors. Do it correctly the first time.



Co-authored-by: Mcrich23 <81453549+Mcrich23@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Oct 22, 2025

@copilot fix the compiler errors. Do it correctly the first time.

Fixed the import statements. Changed @testable import Yams to regular import Yams in all three test files since Yams is a public API and doesn't require testable access. All test files now parse correctly with proper Swift syntax. See commit a40ce7c.

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.

Fix Swift Tests

2 participants