Skip to content

Commit

Permalink
Properly await tasks before disposing of resources (#771)
Browse files Browse the repository at this point in the history
Properly await tasks before disposing of resources in repository mock tests

Co-authored-by: Thomas Cortes <[email protected]>
  • Loading branch information
louis-z and Toa741 authored Oct 15, 2024
1 parent 29e0bc9 commit 34e87a4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
1 change: 0 additions & 1 deletion NGitLab.Mock.Tests/RepositoryMockTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Generic;
using System.Net;
using FluentAssertions;
using NGitLab.Mock.Clients;
using NGitLab.Models;
Expand Down
20 changes: 10 additions & 10 deletions NGitLab.Mock.Tests/UsingVerify/RepositoryMockTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void Test_get_tree_when_subdirectory_does_not_exist_throws_not_found()
}

[Test]
public Task Test_get_tree_item_has_id_and_mode()
public async Task Test_get_tree_item_has_id_and_mode()
{
// Arrange
using var server = new GitLabConfig()
Expand All @@ -50,11 +50,11 @@ public Task Test_get_tree_item_has_id_and_mode()
var tree = repository.GetTreeAsync(new RepositoryGetTreeOptions());

// Assert
return Verify(tree);
await Verify(tree);
}

[Test]
public Task Test_get_tree_item_in_sub_folder()
public async Task Test_get_tree_item_in_sub_folder()
{
// Arrange
using var server = new GitLabConfig()
Expand All @@ -72,11 +72,11 @@ public Task Test_get_tree_item_in_sub_folder()
var tree = repository.GetTreeAsync(new RepositoryGetTreeOptions { Path = "subFolder" });

// Assert
return Verify(tree);
await Verify(tree);
}

[Test]
public Task Test_get_tree_with_recurse()
public async Task Test_get_tree_with_recurse()
{
// Arrange
using var server = new GitLabConfig()
Expand All @@ -94,11 +94,11 @@ public Task Test_get_tree_with_recurse()
var tree = repository.GetTreeAsync(new RepositoryGetTreeOptions { Recursive = true });

// Assert
return Verify(tree);
await Verify(tree);
}

[Test]
public Task Test_get_tree_not_in_main_branch()
public async Task Test_get_tree_not_in_main_branch()
{
// Arrange
using var server = new GitLabConfig()
Expand All @@ -117,11 +117,11 @@ public Task Test_get_tree_not_in_main_branch()
var tree = repository.GetTreeAsync(new RepositoryGetTreeOptions { Ref = "feature", Recursive = true });

// Assert
return Verify(tree);
await Verify(tree);
}

[Test]
public Task Test_get_raw_blob_content()
public async Task Test_get_raw_blob_content()
{
// Arrange
using var server = new GitLabConfig()
Expand All @@ -143,6 +143,6 @@ public Task Test_get_raw_blob_content()
repository.GetRawBlob(item.Id.ToString(), source => source.CopyTo(destination));

// Assert
return Verify(destination);
await Verify(destination);
}
}

0 comments on commit 34e87a4

Please sign in to comment.