Skip to content

Commit

Permalink
removed TestFileSystem and usage
Browse files Browse the repository at this point in the history
  • Loading branch information
arturcic committed Nov 19, 2024
1 parent eaf5d75 commit e8a2fbe
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 151 deletions.
2 changes: 0 additions & 2 deletions src/GitVersion.App.Tests/GitVersion.App.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
<Compile Include="..\GitVersion.Core.Tests\Helpers\ExecutableHelper.cs" Link="Helpers\ExecutableHelper.cs" />
<Compile Include="..\GitVersion.Core.Tests\Helpers\TestConsoleAdapter.cs" Link="Helpers\TestConsoleAdapter.cs" />
<Compile Include="..\GitVersion.Core.Tests\Helpers\TestEnvironment.cs" Link="Helpers\TestEnvironment.cs" />
<Compile Include="..\GitVersion.Core.Tests\Helpers\TestFileSystem.cs" Link="Helpers\TestFileSystem.cs" />
<Compile Include="..\GitVersion.Core.Tests\Helpers\TestLogAppender.cs" Link="Helpers\TestLogAppender.cs" />
<Compile Include="..\GitVersion.Core.Tests\Helpers\TestStream.cs" Link="Helpers\TestStream.cs" />
<Compile Include="..\GitVersion.Core.Tests\Helpers\TestBase.cs" Link="Helpers\TestBase.cs" />
<Compile Include="..\GitVersion.Core.Tests\Helpers\GitVersionCoreTestModule.cs" Link="Helpers\GitVersionCoreTestModule.cs" />
<Compile Include="..\GitVersion.Core.Tests\Extensions\GitVersionVariablesExtensions.cs" Link="Extensions\GitVersionVariablesExtensions.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,8 @@ public void NoWarnOnGitVersionYmlFile()

this.configurationProvider.ProvideForDirectory(this.repoPath);

stringLogger.Length.ShouldBe(0);
var filePath = PathHelper.Combine(this.repoPath, ConfigurationFileLocator.DefaultFileName);
stringLogger.ShouldContain($"Found configuration file at '{filePath}'");
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ public static IDisposable<string> SetupConfigFile(this IFileSystem fileSystem, s
}

var fullPath = PathHelper.Combine(path, fileName);
var directory = PathHelper.GetDirectoryName(fullPath);
if (!fileSystem.DirectoryExists(directory))
{
fileSystem.CreateDirectory(directory);
}

fileSystem.WriteAllText(fullPath, text);

return Disposable.Create(fullPath, () => fileSystem.Delete(fullPath));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public void RegisterTypes(IServiceCollection services)
services.AddModule(new GitVersionConfigurationModule());
services.AddModule(new GitVersionCoreModule());

services.AddSingleton<IFileSystem, TestFileSystem>();
services.AddSingleton<IFileSystem, FileSystem>();
services.AddSingleton<IEnvironment, TestEnvironment>();
services.AddSingleton<ILog, NullLog>();
}
Expand Down
96 changes: 0 additions & 96 deletions src/GitVersion.Core.Tests/Helpers/TestFileSystem.cs

This file was deleted.

38 changes: 0 additions & 38 deletions src/GitVersion.Core.Tests/Helpers/TestStream.cs

This file was deleted.

7 changes: 7 additions & 0 deletions src/GitVersion.Core/Helpers/PathHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ public static string GetTempPath()

public static string GetRepositoryTempPath() => Combine(GetTempPath(), "TestRepositories", Guid.NewGuid().ToString());

public static string GetDirectoryName(string? path)
{
ArgumentNullException.ThrowIfNull(path, nameof(path));

return Path.GetDirectoryName(path)!;
}

public static string GetFullPath(string? path)
{
ArgumentNullException.ThrowIfNull(path, nameof(path));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ private List<string> CalculateDirectoryContents(string root)
{
var fi = new FileInfo(file);
result.Add(fi.Name);
result.Add(File.ReadAllText(file));
result.Add(this.fileSystem.ReadAllText(file));
}
catch (IOException e)
{
Expand Down
2 changes: 0 additions & 2 deletions src/GitVersion.MsBuild.Tests/GitVersion.MsBuild.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@
<Compile Include="..\GitVersion.Core.Tests\Helpers\ExecutableHelper.cs" Link="Helpers\ExecutableHelper.cs" />
<Compile Include="..\GitVersion.Core.Tests\Helpers\TestBase.cs" Link="Helpers\TestBase.cs" />
<Compile Include="..\GitVersion.Core.Tests\Helpers\TestEnvironment.cs" Link="Helpers\TestEnvironment.cs" />
<Compile Include="..\GitVersion.Core.Tests\Helpers\TestFileSystem.cs" Link="Helpers\TestFileSystem.cs" />
<Compile Include="..\GitVersion.Core.Tests\Helpers\TestLogAppender.cs" Link="Helpers\TestLogAppender.cs" />
<Compile Include="..\GitVersion.Core.Tests\Helpers\TestStream.cs" Link="Helpers\TestStream.cs" />
<Compile Include="..\GitVersion.Core.Tests\Extensions\GitToolsTestingExtensions.cs" Link="Extensions\GitToolsTestingExtensions.cs" />
<Compile Include="..\GitVersion.Core.Tests\Extensions\GitVersionVariablesExtensions.cs" Link="Extensions\GitVersionVariablesExtensions.cs" />
<Compile Include="..\GitVersion.Core.Tests\Extensions\MockCollectionExtensions.cs" Link="Extensions\MockCollectionExtensions.cs" />
Expand Down
4 changes: 4 additions & 0 deletions src/GitVersion.Output.Tests/Output/WixFileTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ public void UpdateWixVersionFileWhenFileAlreadyExists()

// fake an already existing file
var file = PathHelper.Combine(workingDir, WixVersionFileUpdater.WixVersionFileName);
if (!fileSystem.DirectoryExists(workingDir))
{
fileSystem.CreateDirectory(workingDir);
}
fileSystem.WriteAllText(file, new('x', 1024 * 1024));

wixVersionFileUpdater.Execute(versionVariables, new(workingDir));
Expand Down
10 changes: 9 additions & 1 deletion src/GitVersion.Output/WixUpdater/WixVersionFileUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,15 @@ public void Execute(GitVersionVariables variables, WixVersionContext context)
var root = doc.DocumentElement;
doc.InsertBefore(xmlDecl, root);

this.fileSystem.Delete(this.wixVersionFile);
if (this.fileSystem.Exists(this.wixVersionFile))
{
this.fileSystem.Delete(this.wixVersionFile);
}

if (!this.fileSystem.DirectoryExists(context.WorkingDirectory))
{
this.fileSystem.CreateDirectory(context.WorkingDirectory);
}
using var fs = this.fileSystem.OpenWrite(this.wixVersionFile);
doc.Save(fs);
}
Expand Down
13 changes: 4 additions & 9 deletions src/GitVersion.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -707,16 +707,11 @@ II.2.12 &lt;HandlesEvent /&gt;&#xD;
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002EJavaScript_002ECodeStyle_002ESettingsUpgrade_002EJsParsFormattingSettingsUpgrader/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002EJavaScript_002ECodeStyle_002ESettingsUpgrade_002EJsWrapperSettingsUpgrader/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EUnitTestFramework_002EMigrations_002EEnableDisabledProvidersMigration/@EntryIndexedValue">True</s:Boolean>


<s:Boolean x:Key="/Default/Environment/UnitTesting/SeparateAppDomainPerAssembly/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/UnitTesting/SeparateAppDomainPerAssembly/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/UnitTesting/ShadowCopy/@EntryValue">False</s:Boolean>




<s:String x:Key="/Default/FilterSettingsManager/AttributeFilterXml/@EntryValue">&lt;data /&gt;</s:String>
<s:String x:Key="/Default/FilterSettingsManager/AttributeFilterXml/@EntryValue">&lt;data /&gt;</s:String>
<s:String x:Key="/Default/FilterSettingsManager/CoverageFilterXml/@EntryValue">&lt;data&gt;&lt;IncludeFilters /&gt;&lt;ExcludeFilters /&gt;&lt;/data&gt;</s:String>
<s:Boolean x:Key="/Default/UserDictionary/Words/=asbjornu/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=gitversion/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Reacheable/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Reacheable/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=veyor/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

0 comments on commit e8a2fbe

Please sign in to comment.