@@ -405,7 +405,7 @@ public final class MockWorkspace {
405
405
406
406
public func set(
407
407
pins: [ PackageReference : CheckoutState ] = [ : ] ,
408
- managedDependencies: [ ManagedDependency ] = [ ] ,
408
+ managedDependencies: [ Workspace . ManagedDependency ] = [ ] ,
409
409
managedArtifacts: [ Workspace . ManagedArtifact ] = [ ]
410
410
) throws {
411
411
let workspace = try self . getOrCreateWorkspace ( )
@@ -426,7 +426,7 @@ public final class MockWorkspace {
426
426
workspace. state. artifacts. add ( artifact)
427
427
}
428
428
429
- try workspace. state. saveState ( )
429
+ try workspace. state. save ( )
430
430
}
431
431
432
432
public func resetState( ) throws {
@@ -447,24 +447,32 @@ public final class MockWorkspace {
447
447
}
448
448
449
449
public struct ManagedDependencyResult {
450
- public let managedDependencies : ManagedDependencies
450
+ public let managedDependencies : Workspace . ManagedDependencies
451
451
452
- public init ( _ managedDependencies: ManagedDependencies ) {
452
+ public init ( _ managedDependencies: Workspace . ManagedDependencies ) {
453
453
self . managedDependencies = managedDependencies
454
454
}
455
455
456
456
public func check( notPresent name: String , file: StaticString = #file, line: UInt = #line) {
457
- let dependency = self . managedDependencies [ forNameOrIdentity: name]
458
- XCTAssert ( dependency == nil , " Unexpectedly found \( name) in managed dependencies " , file: file, line: line)
457
+ self . check ( notPresent: . plain( name) , file: file, line: line)
458
+ }
459
+
460
+ public func check( notPresent dependencyId: PackageIdentity , file: StaticString = #file, line: UInt = #line) {
461
+ let dependency = self . managedDependencies [ dependencyId]
462
+ XCTAssertNil ( dependency, " Unexpectedly found \( dependencyId) in managed dependencies " , file: file, line: line)
459
463
}
460
464
461
465
public func checkEmpty( file: StaticString = #file, line: UInt = #line) {
462
466
XCTAssertEqual ( self . managedDependencies. count, 0 , file: file, line: line)
463
467
}
464
468
465
469
public func check( dependency name: String , at state: State , file: StaticString = #file, line: UInt = #line) {
466
- guard let dependency = managedDependencies [ forNameOrIdentity: name] else {
467
- XCTFail ( " \( name) does not exists " , file: file, line: line)
470
+ self . check ( dependency: . plain( name) , at: state, file: file, line: line)
471
+ }
472
+
473
+ public func check( dependency dependencyId: PackageIdentity , at state: State , file: StaticString = #file, line: UInt = #line) {
474
+ guard let dependency = managedDependencies [ dependencyId] else {
475
+ XCTFail ( " \( dependencyId) does not exists " , file: file, line: line)
468
476
return
469
477
}
470
478
switch state {
@@ -478,8 +486,9 @@ public final class MockWorkspace {
478
486
XCTAssertEqual ( dependency. checkoutState? . branch, branch, file: file, line: line)
479
487
}
480
488
case . edited( let path) :
481
- if dependency . state != . edited( path) {
489
+ guard case . edited( _ , unmanagedPath : path) = dependency . state else {
482
490
XCTFail ( " Expected edited dependency; found ' \( dependency. state) ' instead " , file: file, line: line)
491
+ return
483
492
}
484
493
case . local:
485
494
if dependency. state != . local {
@@ -757,8 +766,8 @@ extension CheckoutState {
757
766
}
758
767
}
759
768
760
- fileprivate extension PackageReference . Kind {
761
- var displayName : String {
769
+ extension PackageReference . Kind {
770
+ fileprivate var displayName : String {
762
771
switch self {
763
772
case . root:
764
773
return " root "
@@ -771,3 +780,12 @@ fileprivate extension PackageReference.Kind {
771
780
}
772
781
}
773
782
}
783
+
784
+ extension Workspace . ManagedDependency {
785
+ fileprivate var checkoutState : CheckoutState ? {
786
+ if case . checkout( let checkoutState) = state {
787
+ return checkoutState
788
+ }
789
+ return . none
790
+ }
791
+ }
0 commit comments