Skip to content

Commit 6003740

Browse files
committed
feat: Implemented more processor tests.
1 parent 4b662a7 commit 6003740

25 files changed

+1415
-355
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
!artifacts/

RelaxVersioner.Core.Tests/AnalyzerEdgeCasesTests.cs

Lines changed: 57 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ public async Task LookupVersionLabel_EmptyRepository_ReturnsDefaultVersion()
3030

3131
// Initialize empty git repository
3232
await TestUtilities.InitializeGitRepositoryWithMainBranch(tempPath);
33-
await TestUtilities.RunGitCommand(tempPath, "config user.email \"[email protected]\"");
34-
await TestUtilities.RunGitCommand(tempPath, "config user.name \"Test User\"");
33+
await TestUtilities.RunGitCommandAsync(tempPath, "config user.email \"[email protected]\"");
34+
await TestUtilities.RunGitCommandAsync(tempPath, "config user.name \"Test User\"");
3535

3636
using var repository = await Repository.Factory.OpenPrimitiveAsync(tempPath);
3737
var version = await Analyzer.LookupVersionLabelAsync(repository, false, default);
@@ -58,22 +58,22 @@ public async Task LookupVersionLabel_DetachedHead_ReturnsCorrectVersion()
5858

5959
// Initialize repository with commits and tag
6060
await TestUtilities.InitializeGitRepositoryWithMainBranch(tempPath);
61-
await TestUtilities.RunGitCommand(tempPath, "config user.email \"[email protected]\"");
62-
await TestUtilities.RunGitCommand(tempPath, "config user.name \"Test User\"");
61+
await TestUtilities.RunGitCommandAsync(tempPath, "config user.email \"[email protected]\"");
62+
await TestUtilities.RunGitCommandAsync(tempPath, "config user.name \"Test User\"");
6363

6464
var testFile = Path.Combine(tempPath, "test.txt");
6565
File.WriteAllText(testFile, "content");
66-
await TestUtilities.RunGitCommand(tempPath, "add test.txt");
67-
await TestUtilities.RunGitCommand(tempPath, "commit -m \"Initial commit\"");
68-
await TestUtilities.RunGitCommand(tempPath, "tag v2.1.0");
66+
await TestUtilities.RunGitCommandAsync(tempPath, "add test.txt");
67+
await TestUtilities.RunGitCommandAsync(tempPath, "commit -m \"Initial commit\"");
68+
await TestUtilities.RunGitCommandAsync(tempPath, "tag v2.1.0");
6969

7070
// Create another commit
7171
File.WriteAllText(testFile, "modified content");
72-
await TestUtilities.RunGitCommand(tempPath, "add test.txt");
73-
await TestUtilities.RunGitCommand(tempPath, "commit -m \"Second commit\"");
72+
await TestUtilities.RunGitCommandAsync(tempPath, "add test.txt");
73+
await TestUtilities.RunGitCommandAsync(tempPath, "commit -m \"Second commit\"");
7474

7575
// Checkout to detached HEAD state (HEAD~1 points to the tagged commit)
76-
await TestUtilities.RunGitCommand(tempPath, "checkout HEAD~1");
76+
await TestUtilities.RunGitCommandAsync(tempPath, "checkout HEAD~1");
7777

7878
using var repository = await Repository.Factory.OpenPrimitiveAsync(tempPath);
7979
var version = await Analyzer.LookupVersionLabelAsync(repository, false, default);
@@ -99,21 +99,21 @@ public async Task LookupVersionLabel_WithInvalidTags_IgnoresInvalidOnes()
9999
Directory.CreateDirectory(tempPath);
100100

101101
await TestUtilities.InitializeGitRepositoryWithMainBranch(tempPath);
102-
await TestUtilities.RunGitCommand(tempPath, "config user.email \"[email protected]\"");
103-
await TestUtilities.RunGitCommand(tempPath, "config user.name \"Test User\"");
102+
await TestUtilities.RunGitCommandAsync(tempPath, "config user.email \"[email protected]\"");
103+
await TestUtilities.RunGitCommandAsync(tempPath, "config user.name \"Test User\"");
104104

105105
var testFile = Path.Combine(tempPath, "test.txt");
106106
File.WriteAllText(testFile, "content");
107-
await TestUtilities.RunGitCommand(tempPath, "add test.txt");
108-
await TestUtilities.RunGitCommand(tempPath, "commit -m \"Initial commit\"");
107+
await TestUtilities.RunGitCommandAsync(tempPath, "add test.txt");
108+
await TestUtilities.RunGitCommandAsync(tempPath, "commit -m \"Initial commit\"");
109109

110110
// Add various invalid and valid tags
111-
await TestUtilities.RunGitCommand(tempPath, "tag invalid-tag");
112-
await TestUtilities.RunGitCommand(tempPath, "tag v1"); // Single component - should be ignored
113-
await TestUtilities.RunGitCommand(tempPath, "tag not-a-version");
114-
await TestUtilities.RunGitCommand(tempPath, "tag v3.2.1"); // Valid
115-
await TestUtilities.RunGitCommand(tempPath, "tag release-notes");
116-
await TestUtilities.RunGitCommand(tempPath, "tag v2.5.0"); // Valid but smaller
111+
await TestUtilities.RunGitCommandAsync(tempPath, "tag invalid-tag");
112+
await TestUtilities.RunGitCommandAsync(tempPath, "tag v1"); // Single component - should be ignored
113+
await TestUtilities.RunGitCommandAsync(tempPath, "tag not-a-version");
114+
await TestUtilities.RunGitCommandAsync(tempPath, "tag v3.2.1"); // Valid
115+
await TestUtilities.RunGitCommandAsync(tempPath, "tag release-notes");
116+
await TestUtilities.RunGitCommandAsync(tempPath, "tag v2.5.0"); // Valid but smaller
117117

118118
using var repository = await Repository.Factory.OpenPrimitiveAsync(tempPath);
119119
var version = await Analyzer.LookupVersionLabelAsync(repository, false, default);
@@ -140,24 +140,24 @@ public async Task LookupVersionLabel_WithOrphanBranch_ReturnsDefaultVersion()
140140
Directory.CreateDirectory(tempPath);
141141

142142
await TestUtilities.InitializeGitRepositoryWithMainBranch(tempPath);
143-
await TestUtilities.RunGitCommand(tempPath, "config user.email \"[email protected]\"");
144-
await TestUtilities.RunGitCommand(tempPath, "config user.name \"Test User\"");
143+
await TestUtilities.RunGitCommandAsync(tempPath, "config user.email \"[email protected]\"");
144+
await TestUtilities.RunGitCommandAsync(tempPath, "config user.name \"Test User\"");
145145

146146
// Create main branch with tagged commit
147147
var testFile = Path.Combine(tempPath, "test.txt");
148148
File.WriteAllText(testFile, "content");
149-
await TestUtilities.RunGitCommand(tempPath, "add test.txt");
150-
await TestUtilities.RunGitCommand(tempPath, "commit -m \"Initial commit\"");
151-
await TestUtilities.RunGitCommand(tempPath, "tag v1.0.0");
149+
await TestUtilities.RunGitCommandAsync(tempPath, "add test.txt");
150+
await TestUtilities.RunGitCommandAsync(tempPath, "commit -m \"Initial commit\"");
151+
await TestUtilities.RunGitCommandAsync(tempPath, "tag v1.0.0");
152152

153153
// Create orphan branch
154-
await TestUtilities.RunGitCommand(tempPath, "checkout --orphan orphan-branch");
155-
await TestUtilities.RunGitCommand(tempPath, "rm -f test.txt");
154+
await TestUtilities.RunGitCommandAsync(tempPath, "checkout --orphan orphan-branch");
155+
await TestUtilities.RunGitCommandAsync(tempPath, "rm -f test.txt");
156156

157157
var orphanFile = Path.Combine(tempPath, "orphan.txt");
158158
File.WriteAllText(orphanFile, "orphan content");
159-
await TestUtilities.RunGitCommand(tempPath, "add orphan.txt");
160-
await TestUtilities.RunGitCommand(tempPath, "commit -m \"Orphan commit\"");
159+
await TestUtilities.RunGitCommandAsync(tempPath, "add orphan.txt");
160+
await TestUtilities.RunGitCommandAsync(tempPath, "commit -m \"Orphan commit\"");
161161

162162
using var repository = await Repository.Factory.OpenPrimitiveAsync(tempPath);
163163
var version = await Analyzer.LookupVersionLabelAsync(repository, false, default);
@@ -184,21 +184,21 @@ public async Task LookupVersionLabel_DeepHistory_PerformsCorrectly()
184184
Directory.CreateDirectory(tempPath);
185185

186186
await TestUtilities.InitializeGitRepositoryWithMainBranch(tempPath);
187-
await TestUtilities.RunGitCommand(tempPath, "config user.email \"[email protected]\"");
188-
await TestUtilities.RunGitCommand(tempPath, "config user.name \"Test User\"");
187+
await TestUtilities.RunGitCommandAsync(tempPath, "config user.email \"[email protected]\"");
188+
await TestUtilities.RunGitCommandAsync(tempPath, "config user.name \"Test User\"");
189189

190190
var testFile = Path.Combine(tempPath, "test.txt");
191191
File.WriteAllText(testFile, "initial");
192-
await TestUtilities.RunGitCommand(tempPath, "add test.txt");
193-
await TestUtilities.RunGitCommand(tempPath, "commit -m \"Initial commit\"");
194-
await TestUtilities.RunGitCommand(tempPath, "tag v1.0.0");
192+
await TestUtilities.RunGitCommandAsync(tempPath, "add test.txt");
193+
await TestUtilities.RunGitCommandAsync(tempPath, "commit -m \"Initial commit\"");
194+
await TestUtilities.RunGitCommandAsync(tempPath, "tag v1.0.0");
195195

196196
// Create deep history (50 commits)
197197
for (int i = 1; i <= 50; i++)
198198
{
199199
File.WriteAllText(testFile, $"content {i}");
200-
await TestUtilities.RunGitCommand(tempPath, "add test.txt");
201-
await TestUtilities.RunGitCommand(tempPath, $"commit -m \"Commit {i}\"");
200+
await TestUtilities.RunGitCommandAsync(tempPath, "add test.txt");
201+
await TestUtilities.RunGitCommandAsync(tempPath, $"commit -m \"Commit {i}\"");
202202
}
203203

204204
using var repository = await Repository.Factory.OpenPrimitiveAsync(tempPath);
@@ -226,20 +226,20 @@ public async Task LookupVersionLabel_MultipleTagsOnSameCommit_ChoosesLargest()
226226
Directory.CreateDirectory(tempPath);
227227

228228
await TestUtilities.InitializeGitRepositoryWithMainBranch(tempPath);
229-
await TestUtilities.RunGitCommand(tempPath, "config user.email \"[email protected]\"");
230-
await TestUtilities.RunGitCommand(tempPath, "config user.name \"Test User\"");
229+
await TestUtilities.RunGitCommandAsync(tempPath, "config user.email \"[email protected]\"");
230+
await TestUtilities.RunGitCommandAsync(tempPath, "config user.name \"Test User\"");
231231

232232
var testFile = Path.Combine(tempPath, "test.txt");
233233
File.WriteAllText(testFile, "content");
234-
await TestUtilities.RunGitCommand(tempPath, "add test.txt");
235-
await TestUtilities.RunGitCommand(tempPath, "commit -m \"Tagged commit\"");
234+
await TestUtilities.RunGitCommandAsync(tempPath, "add test.txt");
235+
await TestUtilities.RunGitCommandAsync(tempPath, "commit -m \"Tagged commit\"");
236236

237237
// Add multiple tags to the same commit
238-
await TestUtilities.RunGitCommand(tempPath, "tag v1.5.0");
239-
await TestUtilities.RunGitCommand(tempPath, "tag v2.0.0");
240-
await TestUtilities.RunGitCommand(tempPath, "tag v1.9.9");
241-
await TestUtilities.RunGitCommand(tempPath, "tag v2.0.1"); // This should be the largest
242-
await TestUtilities.RunGitCommand(tempPath, "tag v1.10.0");
238+
await TestUtilities.RunGitCommandAsync(tempPath, "tag v1.5.0");
239+
await TestUtilities.RunGitCommandAsync(tempPath, "tag v2.0.0");
240+
await TestUtilities.RunGitCommandAsync(tempPath, "tag v1.9.9");
241+
await TestUtilities.RunGitCommandAsync(tempPath, "tag v2.0.1"); // This should be the largest
242+
await TestUtilities.RunGitCommandAsync(tempPath, "tag v1.10.0");
243243

244244
using var repository = await Repository.Factory.OpenPrimitiveAsync(tempPath);
245245
var version = await Analyzer.LookupVersionLabelAsync(repository, false, default);
@@ -265,14 +265,14 @@ public async Task LookupVersionLabel_WithWorkingDirectoryChanges_IncrementsCorre
265265
Directory.CreateDirectory(tempPath);
266266

267267
await TestUtilities.InitializeGitRepositoryWithMainBranch(tempPath);
268-
await TestUtilities.RunGitCommand(tempPath, "config user.email \"[email protected]\"");
269-
await TestUtilities.RunGitCommand(tempPath, "config user.name \"Test User\"");
268+
await TestUtilities.RunGitCommandAsync(tempPath, "config user.email \"[email protected]\"");
269+
await TestUtilities.RunGitCommandAsync(tempPath, "config user.name \"Test User\"");
270270

271271
var testFile = Path.Combine(tempPath, "test.txt");
272272
File.WriteAllText(testFile, "content");
273-
await TestUtilities.RunGitCommand(tempPath, "add test.txt");
274-
await TestUtilities.RunGitCommand(tempPath, "commit -m \"Initial commit\"");
275-
await TestUtilities.RunGitCommand(tempPath, "tag v1.2.3.4"); // 4-component version
273+
await TestUtilities.RunGitCommandAsync(tempPath, "add test.txt");
274+
await TestUtilities.RunGitCommandAsync(tempPath, "commit -m \"Initial commit\"");
275+
await TestUtilities.RunGitCommandAsync(tempPath, "tag v1.2.3.4"); // 4-component version
276276

277277
// Test clean state
278278
using (var repository = await Repository.Factory.OpenPrimitiveAsync(tempPath))
@@ -308,20 +308,20 @@ public async Task LookupVersionLabel_DifferentVersionFormats_ParsesCorrectly()
308308
Directory.CreateDirectory(tempPath);
309309

310310
await TestUtilities.InitializeGitRepositoryWithMainBranch(tempPath);
311-
await TestUtilities.RunGitCommand(tempPath, "config user.email \"[email protected]\"");
312-
await TestUtilities.RunGitCommand(tempPath, "config user.name \"Test User\"");
311+
await TestUtilities.RunGitCommandAsync(tempPath, "config user.email \"[email protected]\"");
312+
await TestUtilities.RunGitCommandAsync(tempPath, "config user.name \"Test User\"");
313313

314314
var testFile = Path.Combine(tempPath, "test.txt");
315315

316316
// Test 2-component version
317317
File.WriteAllText(testFile, "content1");
318-
await TestUtilities.RunGitCommand(tempPath, "add test.txt");
319-
await TestUtilities.RunGitCommand(tempPath, "commit -m \"Commit 1\"");
320-
await TestUtilities.RunGitCommand(tempPath, "tag v5.10");
318+
await TestUtilities.RunGitCommandAsync(tempPath, "add test.txt");
319+
await TestUtilities.RunGitCommandAsync(tempPath, "commit -m \"Commit 1\"");
320+
await TestUtilities.RunGitCommandAsync(tempPath, "tag v5.10");
321321

322322
File.WriteAllText(testFile, "content2");
323-
await TestUtilities.RunGitCommand(tempPath, "add test.txt");
324-
await TestUtilities.RunGitCommand(tempPath, "commit -m \"Commit 2\"");
323+
await TestUtilities.RunGitCommandAsync(tempPath, "add test.txt");
324+
await TestUtilities.RunGitCommandAsync(tempPath, "commit -m \"Commit 2\"");
325325

326326
using var repository = await Repository.Factory.OpenPrimitiveAsync(tempPath);
327327
var version = await Analyzer.LookupVersionLabelAsync(repository, false, default);

0 commit comments

Comments
 (0)