-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
Copy pathGitRepositoryProviderTests.swift
43 lines (37 loc) · 1.74 KB
/
GitRepositoryProviderTests.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift open source project
//
// Copyright (c) 2022 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
import Basics
import _InternalTestSupport
@testable import SourceControl
import XCTest
class GitRepositoryProviderTests: XCTestCase {
func testIsValidDirectory() throws {
try testWithTemporaryDirectory { sandbox in
let provider = GitRepositoryProvider()
// standard repository
let repositoryPath = sandbox.appending("test")
try localFileSystem.createDirectory(repositoryPath)
initGitRepo(repositoryPath)
XCTAssertTrue(try provider.isValidDirectory(repositoryPath))
// no-checkout bare repository
let noCheckoutRepositoryPath = sandbox.appending("test-no-checkout")
try localFileSystem.copy(from: repositoryPath.appending(".git"), to: noCheckoutRepositoryPath)
XCTAssertTrue(try provider.isValidDirectory(noCheckoutRepositoryPath))
// non-git directory
let notGitPath = sandbox.appending("test-not-git")
XCTAssertThrowsError(try provider.isValidDirectory(notGitPath))
// non-git child directory of a git directory
let notGitChildPath = repositoryPath.appending("test-not-git")
XCTAssertThrowsError(try provider.isValidDirectory(notGitChildPath))
}
}
}