Skip to content

Commit 4a2491e

Browse files
committed
[WorkspaceTests] Migrate Workspace tests to new testing infrastructure #2
1 parent 164a09e commit 4a2491e

File tree

4 files changed

+901
-1255
lines changed

4 files changed

+901
-1255
lines changed

Sources/SourceControl/InMemoryGitRepository.swift

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ public final class InMemoryGitRepository {
6060
return Array(tagsMap.keys)
6161
}
6262

63+
/// The list of revisions in the repository.
64+
public var revisions: [RevisionIdentifier] {
65+
return Array(history.keys)
66+
}
67+
6368
/// Indicates whether there are any uncommited changes in the repository.
6469
fileprivate var isDirty = false
6570

@@ -94,7 +99,7 @@ public final class InMemoryGitRepository {
9499
@discardableResult
95100
public func commit() -> String {
96101
// Create a fake hash for thie commit.
97-
let hash = NSUUID().uuidString
102+
let hash = String((NSUUID().uuidString + NSUUID().uuidString).prefix(40))
98103
head.hash = hash
99104
// Store the commit in history.
100105
history[hash] = head.copy()
@@ -230,7 +235,7 @@ extension InMemoryGitRepository: Repository {
230235
}
231236

232237
public func resolveRevision(identifier: String) throws -> Revision {
233-
fatalError("unimplemented")
238+
return Revision(identifier: tagsMap[identifier] ?? identifier)
234239
}
235240

236241
public func exists(revision: Revision) -> Bool {
@@ -253,11 +258,11 @@ extension InMemoryGitRepository: WorkingCheckout {
253258
}
254259

255260
public func hasUnpushedCommits() throws -> Bool {
256-
fatalError("Unimplemented")
261+
return false
257262
}
258263

259264
public func checkout(newBranch: String) throws {
260-
fatalError("Unimplemented")
265+
history[newBranch] = head
261266
}
262267
}
263268

Sources/Workspace/Workspace.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -679,10 +679,12 @@ extension Workspace {
679679
if let path = path {
680680
try fileSystem.createDirectory(editablesPath)
681681
// FIXME: We need this to work with InMem file system too.
682-
try createSymlink(
683-
editablesPath.appending(component: packageName),
684-
pointingAt: path,
685-
relative: false)
682+
if !(fileSystem is InMemoryFileSystem) {
683+
try createSymlink(
684+
editablesPath.appending(component: packageName),
685+
pointingAt: path,
686+
relative: false)
687+
}
686688
}
687689

688690
// Save the new state.

0 commit comments

Comments
 (0)