Skip to content

Commit d9cb3ac

Browse files
committed
add test case for Package.resolved version 2 (Swift >=5.6)
1 parent af8b018 commit d9cb3ac

File tree

1 file changed

+99
-0
lines changed

1 file changed

+99
-0
lines changed

Tests/DangerDependenciesResolverTests/PackageDataProviderTests.swift

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,41 @@ final class PackageDataProviderTests: XCTestCase {
9999
])
100100
}
101101

102+
func testResolvePinnedPackagesReturnsCorrectPinnedPackagesV2() throws {
103+
fileReader.stubbedReadData = { path in
104+
switch path {
105+
case "/usr/franco/Package.resolved":
106+
return Data(self.resolvedPackageV2Text.utf8)
107+
default:
108+
XCTFail("Received unexpected path \(path)")
109+
return Data()
110+
}
111+
}
112+
113+
let packages = try packageDataProvider.resolvePinnedPackages(generatedFolder: "/usr/franco")
114+
115+
XCTAssertEqual(packages, [
116+
.init(name: "aexml",
117+
url: URL(string: "https://github.com/tadija/AEXML")!,
118+
state: .init(version: "4.3.3")),
119+
.init(name: "commandant",
120+
url: URL(string: "https://github.com/Carthage/Commandant.git")!,
121+
state: .init(version: "0.16.0")),
122+
.init(name: "curry",
123+
url: URL(string: "https://github.com/thoughtbot/Curry.git")!,
124+
state: .init(version: "4.0.2")),
125+
.init(name: "jsonutilities",
126+
url: URL(string: "https://github.com/yonaskolb/JSONUtilities.git")!,
127+
state: .init(version: "4.2.0")),
128+
.init(name: "komondor",
129+
url: URL(string: "https://github.com/shibapm/Komondor")!,
130+
state: .init(version: "1.0.4")),
131+
.init(name: "octokit.swift",
132+
url: URL(string: "https://github.com/nerdishbynature/octokit.swift")!,
133+
state: .init(version: "0.9.0")),
134+
])
135+
}
136+
102137
private var packageText: String {
103138
"""
104139
// swift-tools-version:4.2
@@ -216,6 +251,70 @@ final class PackageDataProviderTests: XCTestCase {
216251
}
217252
"""
218253
}
254+
255+
private var resolvedPackageV2Text: String {
256+
"""
257+
{
258+
"pins": [
259+
{
260+
"identity": "aexml",
261+
"kind": "remoteSourceControl",
262+
"location": "https://github.com/tadija/AEXML",
263+
"state": {
264+
"revision": "54bb8ea6fb693dd3f92a89e5fcc19e199fdeedd0",
265+
"version": "4.3.3"
266+
}
267+
},
268+
{
269+
"identity": "commandant",
270+
"kind": "remoteSourceControl",
271+
"location": "https://github.com/Carthage/Commandant.git",
272+
"state": {
273+
"revision": "2cd0210f897fe46c6ce42f52ccfa72b3bbb621a0",
274+
"version": "0.16.0"
275+
}
276+
},
277+
{
278+
"identity": "curry",
279+
"kind": "remoteSourceControl",
280+
"location": "https://github.com/thoughtbot/Curry.git",
281+
"state": {
282+
"revision": "4331dd50bc1db007db664a23f32e6f3df93d4e1a",
283+
"version": "4.0.2"
284+
}
285+
},
286+
{
287+
"identity": "jsonutilities",
288+
"kind": "remoteSourceControl",
289+
"location": "https://github.com/yonaskolb/JSONUtilities.git",
290+
"state": {
291+
"revision": "128d2ffc22467f69569ef8ff971683e2393191a0",
292+
"version": "4.2.0"
293+
}
294+
},
295+
{
296+
"identity": "komondor",
297+
"kind": "remoteSourceControl",
298+
"location": "https://github.com/shibapm/Komondor",
299+
"state": {
300+
"revision": "3cd6d76887816ead5931ddbfb249c2935f518e17",
301+
"version": "1.0.4"
302+
}
303+
},
304+
{
305+
"identity": "octokit.swift",
306+
"kind": "remoteSourceControl",
307+
"location": "https://github.com/nerdishbynature/octokit.swift",
308+
"state": {
309+
"revision": "b63f2ec1b55f26c8e94159d81ad695aeb92f3d4e",
310+
"version": "0.9.0"
311+
}
312+
}
313+
],
314+
"version": 2
315+
}
316+
"""
317+
}
219318
}
220319

221320
final class SpyPrinter: Printing {

0 commit comments

Comments
 (0)