@@ -25,6 +25,7 @@ final class GitKitTests: XCTestCase {
25
25
( " testLog " , testLog) ,
26
26
( " testCommandWithArgs " , testCommandWithArgs) ,
27
27
( " testClone " , testClone) ,
28
+ ( " testCheckoutRemoteTracking " , testCheckoutRemoteTracking) ,
28
29
]
29
30
30
31
// MARK: - helpers
@@ -104,6 +105,25 @@ final class GitKitTests: XCTestCase {
104
105
self . assert ( type: " output " , result: statusOutput, expected: expectation)
105
106
}
106
107
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
+
107
127
#if os(macOS)
108
128
func testAsyncRun( ) throws {
109
129
let path = self . currentPath ( )
0 commit comments