Skip to content

Commit 146679c

Browse files
author
Andrew McKnight
committed
add test
1 parent a360428 commit 146679c

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

Tests/GitKitTests/GitKitTests.swift

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ final class GitKitTests: XCTestCase {
2525
("testLog", testLog),
2626
("testCommandWithArgs", testCommandWithArgs),
2727
("testClone", testClone),
28+
("testCheckoutRemoteTracking", testCheckoutRemoteTracking),
2829
]
2930

3031
// MARK: - helpers
@@ -104,6 +105,25 @@ final class GitKitTests: XCTestCase {
104105
self.assert(type: "output", result: statusOutput, expected: expectation)
105106
}
106107

108+
func testCheckoutRemoteTracking() throws {
109+
let path = self.currentPath()
110+
111+
try self.clean(path: path)
112+
let git = Git(path: path)
113+
114+
try git.run(.clone(url: "https://github.com/binarybirds/shell-kit.git"))
115+
116+
let repoPath = "\(path)/shell-kit"
117+
let repoGit = Git(path: repoPath)
118+
119+
try repoGit.run(.checkout(branch: "feature-branch", create: true, tracking: "origin/main"))
120+
let branchOutput = try repoGit.run(.raw("branch -vv"))
121+
try self.clean(path: path)
122+
123+
XCTAssertTrue(branchOutput.contains("feature-branch"), "New branch should be created")
124+
XCTAssertTrue(branchOutput.contains("origin/main"), "Branch should track origin/main")
125+
}
126+
107127
#if os(macOS)
108128
func testAsyncRun() throws {
109129
let path = self.currentPath()

0 commit comments

Comments
 (0)