8000 Move clone related tests into a separate fixture · rlazev/libgit2sharp@30cd054 · GitHub
[go: up one dir, main page]

Skip to content

Commit 30cd054

Browse files
committed
Move clone related tests into a separate fixture
1 parent 39c2ed2 commit 30cd054

File tree

3 files changed

+83
-72
lines changed

3 files changed

+83
-72
lines changed

LibGit2Sharp.Tests/CloneFixture.cs

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
using System.IO;
2+
using LibGit2Sharp.Tests.TestHelpers;
3+
using Xunit;
4+
using Xunit.Extensions;
5+
6+
namespace LibGit2Sharp.Tests
7+
{
8+
public class CloneFixture : BaseFixture
9+
{
10+
[Theory]
11+
[InlineData("http://github.com/libgit2/TestGitRepository")]
12+
[InlineData("https://github.com/libgit2/TestGitRepository")]
13+
[InlineData("git://github.com/libgit2/TestGitRepository")]
14+
//[InlineData("git@github.com:libgit2/TestGitRepository")]
15+
public void CanClone(string url)
16+
{
17+
var scd = BuildSelfCleaningDirectory();
18+
using (Repository repo = Repository.Clone(url, scd.RootedDirectoryPath))
19+
{
20+
string dir = repo.Info.Path;
21+
Assert.True(Path.IsPathRooted(dir));
22+
Assert.True(Directory.Exists(dir));
23+
24+
Assert.NotNull(repo.Info.WorkingDirectory);
25+
Assert.Equal(Path.Combine(scd.RootedDirectoryPath, ".git" + Path.DirectorySeparatorChar), repo.Info.Path);
26+
Assert.False(repo.Info.IsBare);
27+
28+
Assert.True(File.Exists(Path.Combine(scd.RootedDirectoryPath, "master.txt")));
29+
Assert.Equal(repo.Head.Name, "master");
30+
Assert.Equal(repo.Head.Tip.Id.ToString(), "49322bb17d3acc9146f98c97d078513228bbf3c0");
31+
}
32+
}
33+
34+
[Theory]
35+
[InlineData("http://github.com/libgit2/TestGitRepository")]
36+
[InlineData("https://github.com/libgit2/TestGitRepository")]
37+
[InlineData("git://github.com/libgit2/TestGitRepository")]
38+
//[InlineData("git@github.com:libgit2/TestGitRepository")]
39+
public void CanCloneBarely(string url)
40+
{
41+
var scd = BuildSelfCleaningDirectory();
42+
using (Repository repo = Repository.Clone(url, scd.RootedDirectoryPath, bare: true))
43+
{
44+
string dir = repo.Info.Path;
45+
Assert.True(Path.IsPathRooted(dir));
46+
Assert.True(Directory.Exists(dir));
47+
48+
Assert.Null(repo.Info.WorkingDirectory);
49+
Assert.Equal(scd.RootedDirectoryPath + Path.DirectorySeparatorChar, repo.Info.Path);
50+
Assert.True(repo.Info.IsBare);
51+
}
52+
}
53+
54+
[Theory]
55+
[InlineData("git://github.com/libgit2/TestGitRepository")]
56+
public void WontCheckoutIfAskedNotTo(string url)
57+
{
58+
var scd = BuildSelfCleaningDirectory();
59+
using (Repository repo = Repository.Clone(url, scd.RootedDirectoryPath, checkout: false))
60+
{
61+
Assert.False(File.Exists(Path.Combine(scd.RootedDirectoryPath, "master.txt")));
62+
}
63+
}
64+
65+
[Theory]
66+
[InlineData("git://github.com/libgit2/TestGitRepository")]
67+
public void CallsProgressCallbacks(string url)
68+
{
69+
bool transferWasCalled = false;
70+
bool checkoutWasCalled = false;
71+
72+
var scd = BuildSelfCleaningDirectory();
73+
using (Repository repo = Repository.Clone(url, scd.RootedDirectoryPath,
74+
onTransferProgress: (_) => transferWasCalled = true,
75+
onCheckoutProgress: (a, b, c) => checkoutWasCalled = true))
76+
{
77+
Assert.True(transferWasCalled);
78+
Assert.True(checkoutWasCalled);
79+
}
80+
}
81+
}
82+
}

LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
</ItemGroup>
5959
<ItemGroup>
6060
<Compile Include="CheckoutFixture.cs" />
61+
<Compile Include="CloneFixture.cs" />
6162
<Compile Include="MergeFixture.cs" />
6263
<Compile Include="CleanFixture.cs" />
6364
<Compile Include="CurrentOperationFixture.cs" />

LibGit2Sharp.Tests/RepositoryFixture.cs

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,12 @@
44
using System.Linq;
55
using LibGit2Sharp.Tests.TestHelpers;
66
using Xunit;
7-
using Xunit.Extensions;
87

98
namespace LibGit2Sharp.Tests
109
{
1110
public class RepositoryFixture : BaseFixture
1211
{
1312
private const string commitSha = "8496071c1b46c854b31185ea97743be6a8774479";
14-
private const string TestRepoUrl = "git://github.com/libgit2/TestGitRepository";
1513

1614
[Fact]
1715
public void CanCreateBareRepo()
@@ -468,76 +466,6 @@ public void CanDetectIfTheHeadIsOrphaned()
468466
}
469467
}
470468

471-
[Theory]
472-
[InlineData("http://github.com/libgit2/TestGitRepository")]
473-
[InlineData("https://github.com/libgit2/TestGitRepository")]
474-
[InlineData("git://github.com/libgit2/TestGitRepository")]
475-
//[InlineData("git@github.com:libgit2/TestGitRepository")]
476-
public void CanClone(string url)
477-
{
478-
var scd = BuildSelfCleaningDirectory();
479-
using (Repository repo = Repository.Clone(url, scd.RootedDirectoryPath))
480-
{
481-
string dir = repo.Info.Path;
482-
Assert.True(Path.IsPathRooted(dir));
483-
Assert.True(Directory.Exists(dir));
484-
485-
Assert.NotNull(repo.Info.WorkingDirectory);
486-
Assert.Equal(Path.Combine(scd.RootedDirectoryPath, ".git" + Path.DirectorySeparatorChar), repo.Info.Path);
487-
Assert.False(repo.Info.IsBare);
488-
489-
Assert.True(File.Exists(Path.Combine(scd.RootedDirectoryPath, "master.txt")));
490-
Assert.Equal(repo.Head.Name, "master");
491-
Assert.Equal(repo.Head.Tip.Id.ToString(), "49322bb17d3acc9146f98c97d078513228bbf3c0");
492-
}
493-
}
494-
495-
[Theory]
496-
[InlineData("http://github.com/libgit2/TestGitRepository")]
497-
[InlineData("https://github.com/libgit2/TestGitRepository")]
498-
[InlineData("git://github.com/libgit2/TestGitRepository")]
499-
//[InlineData("git@github.com:libgit2/TestGitRepository")]
500-
public void CanCloneBarely(string url)
501-
{
502-
var scd = BuildSelfCleaningDirectory();
503-
using (Repository repo = Repository.Clone(url, scd.RootedDirectoryPath, bare:true))
504-
{
505-
string dir = repo.Info.Path;
506-
Assert.True(Path.IsPathRooted(dir));
507-
Assert.True(Directory.Exists(dir));
508-
509-
Assert.Null(repo.Info.WorkingDirectory);
510-
Assert.Equal(scd.RootedDirectoryPath + Path.DirectorySeparatorChar, repo.Info.Path);
511-
Assert.True(repo.Info.IsBare);
512-
}
513-
}
514-
515-
[Fact]
516-
public void WontCheckoutIfAskedNotTo()
517-
{
518-
var scd = BuildSelfCleaningDirectory();
519-
using (Repository repo = Repository.Clone(TestRepoUrl, scd.RootedDirectoryPath, checkout:false))
520-
{
521-
Assert.False(File.Exists(Path.Combine(scd.RootedDirectoryPath, "master.txt")));
522-
}
523-
}
524-
525-
[Fact]
526-
public void CallsProgressCallbacks()
527-
{
528-
bool transferWasCalled = false;
529-
bool checkoutWasCalled = false;
530-
531-
var scd = BuildSelfCleaningDirectory();
532-
using (Repository repo = Repository.Clone(TestRepoUrl, scd.RootedDirectoryPath,
533-
onTransferProgress: (_) => transferWasCalled = true,
534-
onCheckoutProgress: (a,b,c) => checkoutWasCalled = true))
535-
{
536-
Assert.True(transferWasCalled);
537-
Assert.True(checkoutWasCalled);
538-
}
539-
}
540-
541469
[Fact]
542470
public void QueryingTheRemoteForADetachedHeadBranchReturnsNull()
543471
{

0 commit comments

Comments
 (0)
0