Skip to content

Add else clause to pattern-match assertions in DestinationCollisionResolverTests #289

@bguidolim

Description

@bguidolim

Problem

In DestinationCollisionResolverTests, the if case let .copyPackFile(_, destination, _) pattern-match blocks silently succeed if the install action is not .copyPackFile. If the resolver erroneously changed a component's install action type, the assertion would never execute and the test would pass.

Example

// Current — silently passes if installAction is not .copyPackFile
if case let .copyPackFile(_, destination, _) = result[0].components[0].installAction {
    #expect(destination == "lint.sh")
}

// Improved — fails explicitly
if case let .copyPackFile(_, destination, _) = result[0].components[0].installAction {
    #expect(destination == "lint.sh")
} else {
    Issue.record("Expected .copyPackFile action")
}

This pattern is already used in ExternalPackAdapterTests.swift (lines 162-164).

Scope

All 7 test methods in DestinationCollisionResolverTests.swift use this pattern — each needs the else { Issue.record(...) } clause added.

References

  • Tests/MCSTests/DestinationCollisionResolverTests.swift
  • Tests/MCSTests/ExternalPackAdapterTests.swift — existing pattern to follow

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions