Skip to content

Commit 6309548

Browse files
committed
Add two failing tests that need to be implemented
1 parent b10fe7a commit 6309548

File tree

2 files changed

+35
-36
lines changed

2 files changed

+35
-36
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//
2+
// File.swift
3+
//
4+
//
5+
// Created by Antoine van der Lee on 10/01/2020.
6+
//
7+
8+
import Foundation
9+
10+
extension String {
11+
12+
/// Gets the Pull Request ID from a `String` based on #{id} format.
13+
/// - returns: An ordered list of found Pull Request identifiers.
14+
func pullRequestIDs() -> [Int] {
15+
return []
16+
}
17+
}
Lines changed: 18 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,29 @@
11
import XCTest
2-
import class Foundation.Bundle
2+
@testable import ChangelogProducerCore
33

44
final class ChangelogProducerTests: XCTestCase {
5-
func testExample() throws {
6-
// This is an example of a functional test case.
7-
// Use XCTAssert and related functions to verify your tests produce the correct
8-
// results.
95

10-
// Some of the APIs that we use below are available in macOS 10.13 and above.
11-
guard #available(macOS 10.13, *) else {
12-
return
13-
}
14-
15-
let fooBinary = productsDirectory.appendingPathComponent("ChangelogProducer")
16-
17-
let process = Process()
18-
process.executableURL = fooBinary
19-
20-
let pipe = Pipe()
21-
process.standardOutput = pipe
22-
23-
try process.run()
24-
process.waitUntilExit()
25-
26-
let data = pipe.fileHandleForReading.readDataToEndOfFile()
27-
let output = String(data: data, encoding: .utf8)
28-
29-
XCTAssertEqual(output, "Hello, world!\n")
6+
/// It should extract pull request IDs from squash merges.
7+
func testPullRequestIDsFromSquashCommits() throws {
8+
let gitLogOutput = """
9+
* Fix bucket deeplinking after adding content (#5130) via Antoine van der Lee
10+
* Fix CI for Coyote #trivial (#5114) via Antoine van der Lee
11+
* Update to 4.3.1 via Antoine van der Lee
12+
"""
13+
XCTAssertEqual(gitLogOutput.pullRequestIDs(), [5114, 5130])
3014
}
3115

32-
/// Returns path to the built products directory.
33-
var productsDirectory: URL {
34-
#if os(macOS)
35-
for bundle in Bundle.allBundles where bundle.bundlePath.hasSuffix(".xctest") {
36-
return bundle.bundleURL.deletingLastPathComponent()
16+
/// It should extract pull request from merge commits.
17+
func testPullRequestIDsFromMergeCommits() throws {
18+
let gitLogOutput = """
19+
* Merge pull request #65 from BalestraPatrick/profiles-devices-endpoints via Antoine van der Lee
20+
* Merge pull request #62 from hexagons/issue/42 via Antoine van der Lee
21+
"""
22+
XCTAssertEqual(gitLogOutput.pullRequestIDs(), [62, 65])
3723
}
38-
fatalError("couldn't find the products directory")
39-
#else
40-
return Bundle.main.bundleURL
41-
#endif
42-
}
4324

4425
static var allTests = [
45-
("testExample", testExample),
26+
("testPullRequestIDsFromSquashCommits", testPullRequestIDsFromSquashCommits),
27+
("testPullRequestIDsFromMergeCommits", testPullRequestIDsFromMergeCommits)
4628
]
4729
}

0 commit comments

Comments
 (0)