Skip to content

Commit 0d52e37

Browse files
Add Repository (Advanced) tests
1 parent a9c9ece commit 0d52e37

1 file changed

Lines changed: 193 additions & 0 deletions

File tree

Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the swift-libgit2 open source project.
4+
//
5+
// Copyright (c) Margins Technologies LLC.
6+
// Licensed under the Apache License, Version 2.0.
7+
//
8+
//===----------------------------------------------------------------------===//
9+
10+
import CLibgit2
11+
import XCTest
12+
@testable import SwiftLibgit2
13+
14+
15+
16+
final class RepositoryAdvancedTests: XCTestCaseStopOnFail
17+
{
18+
func testGitRepositoryCleanup() throws
19+
{
20+
try Repository.withRepository
21+
{
22+
repository in
23+
24+
let repoCleanupResult: GitErrorCode
25+
= gitRepositoryCleanup(repo: repository.pointer)
26+
27+
XCTAssertOK(repoCleanupResult)
28+
}
29+
}
30+
31+
32+
33+
func testGitRepositoryNew() throws
34+
{
35+
var repoPointer: OpaquePointer? = nil
36+
37+
defer
38+
{
39+
gitRepositoryFree(repo: repoPointer)
40+
}
41+
42+
43+
44+
let repoNewResult: GitErrorCode = gitRepositoryNew(out: &repoPointer)
45+
46+
XCTAssertOK(repoNewResult)
47+
XCTAssertNotNil(repoPointer)
48+
}
49+
50+
51+
52+
func testGitRepositoryReinitFileSystem() throws
53+
{
54+
try Repository.withRepository
55+
{
56+
repository in
57+
58+
let repoReinitFileSystemResult: GitErrorCode
59+
= gitRepositoryReinitFileSystem(
60+
repo: repository.pointer,
61+
recurseSubmodules: true
62+
)
63+
64+
XCTAssertOK(repoReinitFileSystemResult)
65+
}
66+
}
67+
68+
69+
70+
func testGitRepositorySetBare() throws
71+
{
72+
try Repository.withRepository
73+
{
74+
repository in
75+
76+
var isRepoBare: Bool
77+
= gitRepositoryIsBare(repo: repository.pointer)
78+
79+
XCTAssertFalse(isRepoBare)
80+
81+
82+
83+
let repoSetBareResult: GitErrorCode
84+
= gitRepositorySetBare(repo: repository.pointer)
85+
86+
XCTAssertOK(repoSetBareResult)
87+
88+
89+
90+
isRepoBare = gitRepositoryIsBare(repo: repository.pointer)
91+
92+
XCTAssertTrue(isRepoBare)
93+
}
94+
}
95+
96+
97+
98+
func testGitRepositorySetConfig() throws
99+
{
100+
try Repository.withConfig
101+
{
102+
repository, configPointer in
103+
104+
let repoSetConfigResult: GitErrorCode = gitRepositorySetConfig(
105+
repo: repository.pointer,
106+
config: configPointer
107+
)
108+
109+
XCTAssertOK(repoSetConfigResult)
110+
}
111+
}
112+
113+
114+
115+
func testGitRepositorySetIndex() throws
116+
{
117+
try Repository.withIndex
118+
{
119+
repository, indexPointer in
120+
121+
let repoSetIndexResult: GitErrorCode = gitRepositorySetIndex(
122+
repo: repository.pointer,
123+
index: indexPointer
124+
)
125+
126+
XCTAssertOK(repoSetIndexResult)
127+
}
128+
}
129+
130+
131+
132+
func testGitRepositorySetODB() throws
133+
{
134+
try Repository.withODB
135+
{
136+
repository, odbPointer in
137+
138+
let repoSetODBResult: GitErrorCode = gitRepositorySetODB(
139+
repo: repository.pointer,
140+
odb: odbPointer
141+
)
142+
143+
XCTAssertOK(repoSetODBResult)
144+
}
145+
}
146+
147+
148+
149+
func testGitRepositorySetRefDB() throws
150+
{
151+
try Repository.withRefDB
152+
{
153+
repository, refDBPointer in
154+
155+
let repoSetRefDBResult: GitErrorCode = gitRepositorySetRefDB(
156+
repo: repository.pointer,
157+
refDB: refDBPointer
158+
)
159+
160+
XCTAssertOK(repoSetRefDBResult)
161+
}
162+
}
163+
164+
165+
166+
func testGitRepositorySubmoduleCacheAll() throws
167+
{
168+
try Repository.withRepository
169+
{
170+
repository in
171+
172+
let repoSubmoduleCacheAllResult: GitErrorCode
173+
= gitRepositorySubmoduleCacheAll(repo: repository.pointer)
174+
175+
XCTAssertOK(repoSubmoduleCacheAllResult)
176+
}
177+
}
178+
179+
180+
181+
func testGitRepositorySubmoduleCacheClear() throws
182+
{
183+
try Repository.withRepository
184+
{
185+
repository in
186+
187+
let repoSubmoduleCacheClearResult: GitErrorCode
188+
= gitRepositorySubmoduleCacheClear(repo: repository.pointer)
189+
190+
XCTAssertOK(repoSubmoduleCacheClearResult)
191+
}
192+
}
193+
}

0 commit comments

Comments
 (0)