Skip to content

Commit

Permalink
Merge #2628 Dispose caches in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
politas committed Dec 31, 2018
2 parents f98b9f0 + 31eb573 commit 48d29f1
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 20 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -28,6 +28,7 @@ All notable changes to this project will be documented in this file.
- [Netkan] Handle multiple game versions from Curse (#2616 by: HebaruSan; reviewed: politas)
- [GUI] Fix UpdateModsList crash on Mono (#2625 by: HebaruSan; reviewed: politas)
- [GUI] Fix System.ObjectDisposedException for TransparentTextBox (#2619 by: DasSkelett; reviewed: HebaruSan)
- [Build] Dispose caches in tests (#2628 by: HebaruSan; reviewed: politas)

## v1.25.4 Kennedy

Expand Down
4 changes: 4 additions & 0 deletions Tests/Core/Cache.cs
Expand Up @@ -26,6 +26,10 @@ public void MakeCache()
[TearDown]
public void RemoveCache()
{
cache.Dispose();
cache = null;
module_cache.Dispose();
module_cache = null;
Directory.Delete(cache_dir, true);
}

Expand Down
2 changes: 2 additions & 0 deletions Tests/NetKAN/Sources/Curse/CurseApiTests.cs
Expand Up @@ -28,6 +28,8 @@ public void TestFixtureSetup()
[OneTimeTearDown]
public void TestFixtureTearDown()
{
_cache.Dispose();
_cache = null;
Directory.Delete(_cachePath, recursive: true);
}

Expand Down
2 changes: 2 additions & 0 deletions Tests/NetKAN/Sources/Github/GithubApiTests.cs
Expand Up @@ -30,6 +30,8 @@ public void TestFixtureSetup()
[OneTimeTearDown]
public void TestFixtureTearDown()
{
_cache.Dispose();
_cache = null;
Directory.Delete(_cachePath, recursive: true);
}

Expand Down
42 changes: 22 additions & 20 deletions Tests/NetKAN/Sources/Jenkins/JenkinsApiTests.cs
Expand Up @@ -7,48 +7,50 @@

namespace Tests.NetKAN.Sources.Jenkins
{
[TestFixture]
public sealed class JenkinsApiTests
{
[OneTimeSetUp]
[TestFixture]
public sealed class JenkinsApiTests
{
[OneTimeSetUp]
public void TestFixtureSetup()
{
_cachePath = Path.Combine(
Path.GetTempPath(),
"CKAN",
Guid.NewGuid().ToString("N")
);
Path.GetTempPath(),
"CKAN",
Guid.NewGuid().ToString("N")
);
Directory.CreateDirectory(_cachePath);
_cache = new NetFileCache(_cachePath);
}

[OneTimeTearDown]
public void TestFixtureTearDown()
{
_cache.Dispose();
_cache = null;
Directory.Delete(_cachePath, recursive: true);
}


[Test]
[Category("FlakyNetwork")]
[Category("Online")]
public void GetLatestBuild_ModuleManager_Works()
{
// Arrange
[Test]
[Category("FlakyNetwork")]
[Category("Online")]
public void GetLatestBuild_ModuleManager_Works()
{
// Arrange
IJenkinsApi sut = new JenkinsApi(new CachingHttpService(_cache));

// Act
JenkinsBuild build = sut.GetLatestBuild(
new JenkinsRef("#/ckan/jenkins/https://ksp.sarbian.com/jenkins/job/ModuleManager/"),
new JenkinsOptions()
);
JenkinsBuild build = sut.GetLatestBuild(
new JenkinsRef("#/ckan/jenkins/https://ksp.sarbian.com/jenkins/job/ModuleManager/"),
new JenkinsOptions()
);

// Assert
Assert.IsNotNull(build.Url);
Assert.IsNotNull(build.Artifacts);
}
}

private string _cachePath;
private NetFileCache _cache;
}
}
}
2 changes: 2 additions & 0 deletions Tests/NetKAN/Sources/Spacedock/SpacedockApiTests.cs
Expand Up @@ -28,6 +28,8 @@ public void TestFixtureSetup()
[OneTimeTearDown]
public void TestFixtureTearDown()
{
_cache.Dispose();
_cache = null;
Directory.Delete(_cachePath, recursive: true);
}

Expand Down

0 comments on commit 48d29f1

Please sign in to comment.