Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit c6c1437

Browse files
committed
RepositoryCloneServiceTests:Rewrite test for readability.
- Assert.ThrowAsync statement have been shortened. - failing url and dev bar have been factored into clonePath and cloneUrl.
1 parent 894875e commit c6c1437

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

test/GitHub.App.UnitTests/Services/RepositoryCloneServiceTests.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,21 +122,19 @@ await usageTracker.Received(numberOfCalls).IncrementCounter(
122122
((MemberExpression)x.Body).Member.Name == counterName));
123123
}
124124

125-
[Test]
126-
public async Task CleansDirectoryOnCloneFailed()
125+
[TestCase("https://github.com/failing/url", @"c:\dev\bar")]
126+
public async Task CleansDirectoryOnCloneFailed(string cloneUrl, string clonePath)
127127
{
128128
var serviceProvider = Substitutes.GetServiceProvider();
129129
var operatingSystem = serviceProvider.GetOperatingSystem();
130130
var vsGitServices = serviceProvider.GetVSGitServices();
131131
var cloneService = CreateRepositoryCloneService(serviceProvider);
132132

133-
Assert.ThrowsAsync<Exception>(async () => {
134-
await cloneService.CloneRepository("https://github.com/failing/url", @"c:\dev\bar");
135-
});
133+
Assert.ThrowsAsync<Exception>(() => cloneService.CloneRepository(cloneUrl, clonePath));
136134

137-
operatingSystem.Directory.Received().CreateDirectory(@"c:\dev\bar");
138-
operatingSystem.Directory.Received().DeleteDirectory(@"c:\dev\bar");
139-
await vsGitServices.Received().Clone("https://github.com/failing/url", @"c:\dev\bar", true);
135+
operatingSystem.Directory.Received().CreateDirectory(clonePath);
136+
operatingSystem.Directory.Received().DeleteDirectory(clonePath);
137+
await vsGitServices.Received().Clone(cloneUrl, clonePath, true);
140138
}
141139

142140
static RepositoryCloneService CreateRepositoryCloneService(IGitHubServiceProvider sp)

0 commit comments

Comments
 (0)