Thanks to visit codestin.com
Credit goes to github.com

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

Commit 6a7a166

Browse files
committed
Clone the test repository only when required
1 parent 4516af5 commit 6a7a166

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

LibGit2Sharp.Tests/ObjectDatabaseFixture.cs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public void CanTellIfObjectsExists(string sha, bool shouldExists)
2828
[Fact]
2929
public void CanCreateABlobFromAFileInTheWorkingDirectory()
3030
{
31-
string path = CloneStandardTestRepo();
31+
string path = InitNewRepository();
3232
using (var repo = new Repository(path))
3333
{
3434
Assert.Equal(FileStatus.Nonexistent, repo.Index.RetrieveStatus("hello.txt"));
@@ -51,7 +51,7 @@ public void CanCreateABlobFromAFileInTheWorkingDirectory()
5151
[Fact]
5252
public void CanCreateABlobIntoTheDatabaseOfABareRepository()
5353
{
54-
string path = CloneBareTestRepo();
54+
string path = InitNewRepository();
5555

5656
SelfCleaningDirectory directory = BuildSelfCleaningDirectory();
5757

@@ -83,7 +83,7 @@ public void CanCreateABlobIntoTheDatabaseOfABareRepository()
8383
[InlineData("e9671e138a780833cb689753570fd10a55be84fb", "dummy.guess")]
8484
public void CanCreateABlobFromAStream(string expectedSha, string hintPath)
8585
{
86-
string path = CloneBareTestRepo();
86+
string path = InitNewRepository();
8787

8888
var sb = new StringBuilder();
8989
for (int i = 0; i < 6; i++)
@@ -114,7 +114,7 @@ public void CanCreateABlobFromAStream(string expectedSha, string hintPath)
114114
[InlineData(8192, 4097)]
115115
public void CanCreateABlobFromAStreamWithANumberOfBytesToConsume(int contentSize, int numberOfBytesToConsume)
116116
{
117-
string path = CloneBareTestRepo();
117+
string path = InitNewRepository();
118118

119119
var sb = new StringBuilder();
120120
for (int i = 0; i < contentSize; i++)
@@ -135,10 +135,12 @@ public void CanCreateABlobFromAStreamWithANumberOfBytesToConsume(int contentSize
135135
[Fact]
136136
public void CreatingABlobFromANonReadableStreamThrows()
137137
{
138-
string path = CloneStandardTestRepo();
138+
string path = InitNewRepository();
139139

140-
using (var stream = new FileStream(Path.Combine(path, "file.txt"), FileMode.CreateNew, FileAccess.Write))
141140
using (var repo = new Repository(path))
141+
using (var stream = new FileStream(
142+
Path.Combine(repo.Info.WorkingDirectory, "file.txt"),
143+
FileMode.CreateNew, FileAccess.Write))
142144
{
143145
Assert.Throws<ArgumentException>(() => repo.ObjectDatabase.CreateBlob(stream));
144146
}
@@ -218,7 +220,7 @@ public void RemovingANonExistingEntryFromATreeDefinitionHasNoSideEffect()
218220
[Fact]
219221
public void CanCreateAnEmptyTree()
220222
{
221-
string path = CloneBareTestRepo();
223+
string path = InitNewRepository();
222224
using (var repo = new Repository(path))
223225
{
224226
var td = new TreeDefinition();
@@ -364,7 +366,7 @@ public void CanCreateABinaryBlobFromAStream()
364366
{
365367
var binaryContent = new byte[] { 0, 1, 2, 3, 4, 5 };
366368

367-
string path = CloneBareTestRepo();
369+
string path = InitNewRepository();
368370
using (var repo = new Repository(path))
369371
{
370372
using (var stream = new MemoryStream(binaryContent))

0 commit comments

Comments
 (0)