fix(git-tests): Create per-test specific databases
This commit is contained in:
parent
cb01efd323
commit
cf782211aa
3 changed files with 40 additions and 6 deletions
|
|
@ -24,13 +24,15 @@ public class AddRegistrationTests
|
|||
{
|
||||
Settings.UseFileName($"{nameof(BasicRepoRegistration)}_{testData.testId}");
|
||||
|
||||
var gitManager = GitManager.InternalFreshInstance;
|
||||
var gitManager = GitManager.InternalFreshInstance(nameof(BasicRepoRegistration));
|
||||
|
||||
var repoRegistration = gitManager.RegisterRepo("Test:/some/test/repo", testData.path);
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendLine($"Attempted to register: {testData.path}")
|
||||
.AppendLine($"Registration result: {repoRegistration}");
|
||||
|
||||
gitManager.DeleteDatabase();
|
||||
|
||||
return Verify(sb, Settings);
|
||||
}
|
||||
|
||||
|
|
@ -39,11 +41,13 @@ public class AddRegistrationTests
|
|||
{
|
||||
Settings.UseFileName(nameof(RepoRegistrationWithEmptyName));
|
||||
|
||||
var gitManager = GitManager.InternalFreshInstance;
|
||||
var gitManager = GitManager.InternalFreshInstance(nameof(RepoRegistrationWithEmptyName));
|
||||
var testRepoAbsolutePath = "Test:/some/test/repo";
|
||||
|
||||
var emptyName = gitManager.RegisterRepo(testRepoAbsolutePath, "");
|
||||
|
||||
gitManager.DeleteDatabase();
|
||||
|
||||
Assert.Equal("repo", emptyName);
|
||||
}
|
||||
|
||||
|
|
@ -52,13 +56,15 @@ public class AddRegistrationTests
|
|||
{
|
||||
Settings.UseFileName(nameof(RepoRegistrationWithNullName));
|
||||
|
||||
var gitManager = GitManager.InternalFreshInstance;
|
||||
var gitManager = GitManager.InternalFreshInstance(nameof(RepoRegistrationWithNullName));
|
||||
var testRepoAbsolutePath = "Test:/some/test/repo";
|
||||
|
||||
// Name is technically not-nullable, but string is a reference type so null can be passed in so we should test
|
||||
// it regardless
|
||||
var nullName = gitManager.RegisterRepo(testRepoAbsolutePath, null!);
|
||||
|
||||
gitManager.DeleteDatabase();
|
||||
|
||||
Assert.Equal("repo", nullName);
|
||||
}
|
||||
|
||||
|
|
@ -67,11 +73,13 @@ public class AddRegistrationTests
|
|||
{
|
||||
Settings.UseFileName(nameof(RepoRegistrationWithWhitespaceName));
|
||||
|
||||
var gitManager = GitManager.InternalFreshInstance;
|
||||
var gitManager = GitManager.InternalFreshInstance(nameof(RepoRegistrationWithWhitespaceName));
|
||||
var testRepoAbsolutePath = "Test:/some/test/repo";
|
||||
|
||||
var whitespaceName = gitManager.RegisterRepo(testRepoAbsolutePath, " ");
|
||||
|
||||
gitManager.DeleteDatabase();
|
||||
|
||||
Assert.Equal("repo", whitespaceName);
|
||||
}
|
||||
|
||||
|
|
@ -80,7 +88,7 @@ public class AddRegistrationTests
|
|||
{
|
||||
Settings.UseFileName(nameof(RepoRegistrationWithWhitespaceName));
|
||||
|
||||
var gitManager = GitManager.InternalFreshInstance;
|
||||
var gitManager = GitManager.InternalFreshInstance(nameof(RepoRegistrationWithWhitespaceName));
|
||||
var testRepoAbsolutePath = "Test:/some/test/repo";
|
||||
string[] paths = ["test", "nested", "path"];
|
||||
var names = (NormalSeparator: string.Join(Path.DirectorySeparatorChar, paths), AltSeparator: string.Join(Path.AltDirectorySeparatorChar, paths));
|
||||
|
|
@ -93,6 +101,8 @@ public class AddRegistrationTests
|
|||
Assert.Equal(Path.Combine(paths[..1]), secondRegistration);
|
||||
|
||||
Assert.Throws<Exception>(() => gitManager.RegisterRepo(testRepoAbsolutePath, Path.Combine(paths[..1])));
|
||||
|
||||
gitManager.DeleteDatabase();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -100,7 +110,7 @@ public class AddRegistrationTests
|
|||
{
|
||||
Settings.UseFileName(nameof(RepoRegistrationWithWhitespaceName));
|
||||
|
||||
var gitManager = GitManager.InternalFreshInstance;
|
||||
var gitManager = GitManager.InternalFreshInstance(nameof(RepoRegistrationWithWhitespaceName));
|
||||
var testRepoAbsolutePath = "Test:/some/test/repo";
|
||||
string[] paths = ["test", "nested", "path"];
|
||||
var names = (NormalSeparator: string.Join(Path.DirectorySeparatorChar, paths), AltSeparator: string.Join(Path.AltDirectorySeparatorChar, paths));
|
||||
|
|
@ -110,6 +120,8 @@ public class AddRegistrationTests
|
|||
var secondRegistration = gitManager.RegisterRepo(testRepoAbsolutePath, Path.Combine(paths[..1]));
|
||||
var differentPathSeparatorRegistration = gitManager.RegisterRepo(testRepoAbsolutePath, names.AltSeparator);
|
||||
|
||||
gitManager.DeleteDatabase();
|
||||
|
||||
Assert.Equal(Path.Combine(paths), firstRegistration);
|
||||
Assert.Equal(Path.Combine(paths[..1]), secondRegistration);
|
||||
Assert.Equal(names.AltSeparator, differentPathSeparatorRegistration);
|
||||
|
|
|
|||
Loading…
Reference in a new issue