@@ -56,18 +56,18 @@ final class CleanServiceTests: TuistUnitTestCase {
5656
5757 func test_run_with_category_cleans_category( ) async throws {
5858 // Given
59- let cachePaths = try createFolders ( [ " tuist/Manifests " , " tuist/ProjectDescriptionHelpers " ] )
59+ let rootDirectory = try temporaryPath ( )
60+ let cachePaths = try await createFiles ( [ " tuist/Manifests/manifest.json " , " tuist/ProjectDescriptionHelpers/File.swift " ] )
6061
61- let cachePath = cachePaths [ 0 ] . parentDirectory. parentDirectory
6262 given ( cacheDirectoriesProvider)
6363 . cacheDirectory ( for: . value( . manifests) )
64- . willReturn ( cachePaths [ 0 ] )
64+ . willReturn ( cachePaths [ 0 ] . parentDirectory )
6565 given ( cacheDirectoriesProvider)
6666 . cacheDirectory ( for: . value( . projectDescriptionHelpers) )
67- . willReturn ( cachePaths [ 1 ] )
67+ . willReturn ( cachePaths [ 1 ] . parentDirectory )
6868 given ( rootDirectoryLocator)
6969 . locate ( from: . any)
70- . willReturn ( cachePath )
70+ . willReturn ( rootDirectory )
7171 given ( manifestFilesLocator)
7272 . locatePackageManifest ( at: . any)
7373 . willReturn ( nil )
@@ -87,19 +87,20 @@ final class CleanServiceTests: TuistUnitTestCase {
8787
8888 func test_run_with_dependencies_cleans_dependencies( ) async throws {
8989 // Given
90- let localPaths = try createFolders ( [ " Tuist/.build " , " Tuist/ProjectDescriptionHelpers " ] )
90+ let rootDirectory = try temporaryPath ( )
91+ let localPaths = try await createFiles ( [ " Tuist/.build/file " , " Tuist/ProjectDescriptionHelpers/File.swift " ] )
9192
9293 given ( rootDirectoryLocator)
9394 . locate ( from: . any)
94- . willReturn ( localPaths [ 0 ] . parentDirectory )
95+ . willReturn ( rootDirectory )
9596 given ( manifestFilesLocator)
9697 . locatePackageManifest ( at: . any)
9798 . willReturn (
98- localPaths [ 1 ] . parentDirectory
99- . appending ( component : Constants . SwiftPackageManager. packageSwiftName)
99+ rootDirectory
100+ . appending ( components : " Tuist " , Constants . SwiftPackageManager. packageSwiftName)
100101 )
101102
102- let cachePath = localPaths [ 0 ] . parentDirectory . parentDirectory
103+ let cachePath = rootDirectory
103104 given ( cacheDirectoriesProvider)
104105 . cacheDirectory ( )
105106 . willReturn ( cachePath)
@@ -119,15 +120,16 @@ final class CleanServiceTests: TuistUnitTestCase {
119120
120121 func test_run_with_dependencies_cleans_dependencies_when_package_is_in_root( ) async throws {
121122 // Given
122- let localPaths = try createFolders ( [ " .build " , " Tuist/ProjectDescriptionHelpers " ] )
123+ let rootDirectory = try temporaryPath ( )
124+ let localPaths = try await createFiles ( [ " .build/file " , " Tuist/ProjectDescriptionHelpers/file " ] )
123125
124126 given ( rootDirectoryLocator)
125127 . locate ( from: . any)
126- . willReturn ( localPaths [ 0 ] . parentDirectory )
128+ . willReturn ( rootDirectory )
127129 given ( manifestFilesLocator)
128130 . locatePackageManifest ( at: . any)
129131 . willReturn (
130- localPaths [ 0 ] . parentDirectory
132+ rootDirectory
131133 . appending ( component: Constants . SwiftPackageManager. packageSwiftName)
132134 )
133135
@@ -151,11 +153,11 @@ final class CleanServiceTests: TuistUnitTestCase {
151153
152154 func test_run_without_category_cleans_all( ) async throws {
153155 // Given
154- let cachePaths = try createFolders ( [ " tuist/Manifests " ] )
156+ let cachePaths = try await createFiles ( [ " tuist/Manifests/hash " ] )
155157
156158 given ( cacheDirectoriesProvider)
157159 . cacheDirectory ( for: . any)
158- . willReturn ( cachePaths [ 0 ] )
160+ . willReturn ( cachePaths [ 0 ] . parentDirectory )
159161
160162 let projectPath = try temporaryPath ( )
161163 given ( rootDirectoryLocator)
@@ -171,6 +173,8 @@ final class CleanServiceTests: TuistUnitTestCase {
171173 components: Constants . SwiftPackageManager. packageBuildDirectoryName
172174 )
173175 try fileHandler. createFolder ( swiftPackageManagerBuildPath)
176+ let swiftPackageManagerBuildFile = swiftPackageManagerBuildPath. appending ( component: " file " )
177+ try await fileSystem. touch ( swiftPackageManagerBuildFile)
174178
175179 // When
176180 try await subject. run (
@@ -182,8 +186,8 @@ final class CleanServiceTests: TuistUnitTestCase {
182186 // Then
183187 let cachePathExists = try await fileSystem. exists ( cachePaths [ 0 ] )
184188 XCTAssertFalse ( cachePathExists)
185- let swiftPackageManagerBuildPathExists = try await fileSystem. exists ( swiftPackageManagerBuildPath )
186- XCTAssertFalse ( swiftPackageManagerBuildPathExists )
189+ let swiftPackageManagerBuildFileExists = try await fileSystem. exists ( swiftPackageManagerBuildFile )
190+ XCTAssertFalse ( swiftPackageManagerBuildFileExists )
187191 }
188192
189193 func test_run_with_remote( ) async throws {
0 commit comments