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

Commit d45fd8e

Browse files
Update test to clone a different Git repository
1 parent 24cfde5 commit d45fd8e

1 file changed

Lines changed: 15 additions & 17 deletions

File tree

RepoLinterTests/GitTest.cs

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ public class GitTest
1010
private readonly ITestOutputHelper _testOutputHelper;
1111
private readonly string _path;
1212
private readonly GlobalConfiguration _config = new();
13-
13+
1414
public GitTest(ITestOutputHelper testOutputHelper)
1515
{
1616
_testOutputHelper = testOutputHelper;
1717
_path = Path.Join(Path.GetTempPath(), Path.GetRandomFileName());
1818
InitFakeRepo();
1919
}
20-
20+
2121
~GitTest()
2222
{
2323
Directory.Delete(_path, true);
@@ -26,10 +26,10 @@ public GitTest(ITestOutputHelper testOutputHelper)
2626
private void InitFakeRepo()
2727
{
2828
Directory.CreateDirectory(_path);
29-
29+
3030
// Create a .gitingore file and add a file to ignore
3131
File.WriteAllText(Path.Join(_path, ".gitignore"), "ignored.txt");
32-
32+
3333
var initialized = RunGitCommand(_path, "init");
3434
if (!initialized)
3535
{
@@ -38,19 +38,19 @@ private void InitFakeRepo()
3838

3939
var x = RunGitCommand(_path, "config --local user.email \"test@example.com\"");
4040
var y = RunGitCommand(_path, "config --local user.name \"Test\"");
41-
41+
4242
if (!x || !y)
4343
{
4444
throw new GitException("Failed to set git user");
4545
}
46-
46+
4747
// Create a commit
4848
File.WriteAllText(Path.Join(_path, "README.md"), "# Hello World");
4949
RunGitCommand(_path, "add .");
5050
RunGitCommand(_path, "branch -m main");
5151
RunGitCommand(_path, "commit -m Hello");
5252
}
53-
53+
5454
private static bool RunGitCommand(string path, string command)
5555
{
5656
var process = new Process
@@ -65,41 +65,41 @@ private static bool RunGitCommand(string path, string command)
6565
CreateNoWindow = true
6666
}
6767
};
68-
68+
6969
var started = process.Start();
7070
if (!started)
7171
{
7272
throw new Exception("Failed to start git command");
7373
}
74-
74+
7575
process.WaitForExit();
7676
return process.ExitCode == 0;
7777
}
7878

7979
[Fact]
8080
public void CloneGitRepository()
8181
{
82-
var git = new Git(new Uri("https://github.com/EmilZackrisson/TraefikAPI"), _config);
82+
var git = new Git(new Uri("https://github.com/githubtraining/hellogitworld"), _config);
8383
git.Clone();
8484
var directory = Path.Join(git.ParentDirectory, git.RepositoryName);
8585
_testOutputHelper.WriteLine("Git repository cloned to: " + directory);
8686
Assert.True(Directory.Exists(directory));
8787
}
88-
88+
8989
[Fact]
9090
public void CreateGitObjectWithLocalPath()
9191
{
9292
Git git = new Git(_path);
9393
Assert.Equal(_path, Path.Join(git.ParentDirectory, git.RepositoryName));
9494
}
95-
95+
9696
[Fact]
9797
public void CreateGitObjectWithLocalPathThatDoesNotExist()
9898
{
9999
var path = Path.Join(_path, Path.GetRandomFileName());
100100
Assert.Throws<DirectoryNotFoundException>(() => new Git(path));
101101
}
102-
102+
103103
[Fact]
104104
public void CreateGitObjectWithLocalPathThatIsNotAGitRepository()
105105
{
@@ -114,7 +114,7 @@ public void GetCommitCount()
114114
var git = new Git(_path);
115115
Assert.Equal(1, git.GetCommitCount());
116116
}
117-
117+
118118
[Fact]
119119
public void GetContributors()
120120
{
@@ -131,7 +131,7 @@ public void IgnoreFile()
131131
var ignored = ignore.IsIgnored(pathToIgnoredFile);
132132
Assert.True(ignored);
133133
}
134-
134+
135135
[Fact]
136136
public void ShouldNotIgnoreFile()
137137
{
@@ -140,6 +140,4 @@ public void ShouldNotIgnoreFile()
140140
var ignored = ignore.IsIgnored(pathToNotIgnoredFile);
141141
Assert.False(ignored);
142142
}
143-
144-
145143
}

0 commit comments

Comments
 (0)