@@ -378,7 +378,7 @@ public final class MockWorkspace {
378
378
379
379
public func set(
380
380
pins: [ PackageReference : CheckoutState ] = [ : ] ,
381
- managedDependencies: [ ManagedDependency ] = [ ] ,
381
+ managedDependencies: [ Workspace . ManagedDependency ] = [ ] ,
382
382
managedArtifacts: [ Workspace . ManagedArtifact ] = [ ]
383
383
) throws {
384
384
let workspace = try self . getOrCreateWorkspace ( )
@@ -399,7 +399,7 @@ public final class MockWorkspace {
399
399
workspace. state. artifacts. add ( artifact)
400
400
}
401
401
402
- try workspace. state. saveState ( )
402
+ try workspace. state. save ( )
403
403
}
404
404
405
405
public func resetState( ) throws {
@@ -420,24 +420,32 @@ public final class MockWorkspace {
420
420
}
421
421
422
422
public struct ManagedDependencyResult {
423
- public let managedDependencies : ManagedDependencies
423
+ public let managedDependencies : Workspace . ManagedDependencies
424
424
425
- public init ( _ managedDependencies: ManagedDependencies ) {
425
+ public init ( _ managedDependencies: Workspace . ManagedDependencies ) {
426
426
self . managedDependencies = managedDependencies
427
427
}
428
428
429
429
public func check( notPresent name: String , file: StaticString = #file, line: UInt = #line) {
430
- let dependency = self . managedDependencies [ forNameOrIdentity: name]
431
- XCTAssert ( dependency == nil , " Unexpectedly found \( name) in managed dependencies " , file: file, line: line)
430
+ self . check ( notPresent: . plain( name) , file: file, line: line)
431
+ }
432
+
433
+ public func check( notPresent dependencyId: PackageIdentity , file: StaticString = #file, line: UInt = #line) {
434
+ let dependency = self . managedDependencies [ dependencyId]
435
+ XCTAssertNil ( dependency, " Unexpectedly found \( dependencyId) in managed dependencies " , file: file, line: line)
432
436
}
433
437
434
438
public func checkEmpty( file: StaticString = #file, line: UInt = #line) {
435
439
XCTAssertEqual ( self . managedDependencies. count, 0 , file: file, line: line)
436
440
}
437
441
438
442
public func check( dependency name: String , at state: State , file: StaticString = #file, line: UInt = #line) {
439
- guard let dependency = managedDependencies [ forNameOrIdentity: name] else {
440
- XCTFail ( " \( name) does not exists " , file: file, line: line)
443
+ self . check ( dependency: . plain( name) , at: state, file: file, line: line)
444
+ }
445
+
446
+ public func check( dependency dependencyId: PackageIdentity , at state: State , file: StaticString = #file, line: UInt = #line) {
447
+ guard let dependency = managedDependencies [ dependencyId] else {
448
+ XCTFail ( " \( dependencyId) does not exists " , file: file, line: line)
441
449
return
442
450
}
443
451
switch state {
@@ -451,8 +459,9 @@ public final class MockWorkspace {
451
459
XCTAssertEqual ( dependency. checkoutState? . branch, branch, file: file, line: line)
452
460
}
453
461
case . edited( let path) :
454
- if dependency . state != . edited( path) {
462
+ guard case . edited( _ , unmanagedPath : path) = dependency . state else {
455
463
XCTFail ( " Expected edited dependency; found ' \( dependency. state) ' instead " , file: file, line: line)
464
+ return
456
465
}
457
466
case . local:
458
467
if dependency. state != . local {
@@ -726,3 +735,12 @@ extension CheckoutState {
726
735
}
727
736
}
728
737
}
738
+
739
+ extension Workspace . ManagedDependency {
740
+ public var checkoutState : CheckoutState ? {
741
+ if case . checkout( let checkoutState) = state {
742
+ return checkoutState
743
+ }
744
+ return nil
745
+ }
746
+ }
0 commit comments