Skip to content

Commit

Permalink
test: Add a test case when no plugins are loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
MrDave1999 committed Jan 12, 2024
1 parent 648d5c0 commit 8e98451
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions samples/Example.PluginApp/Test/SqlTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public async Task Get_WhenSqlCodeIsRetrieved_ShouldReturnsHttpStatusCodeOk(
string expectedResult)
{
// Arrange
Environment.SetEnvironmentVariable("PLUGINS", "");
using var factory = new WebApplicationFactory<Program>();
var client = factory.CreateClient();

Expand All @@ -25,4 +26,20 @@ public async Task Get_WhenSqlCodeIsRetrieved_ShouldReturnsHttpStatusCodeOk(
httpResponse.StatusCode.Should().Be(HttpStatusCode.OK);
result.Should().Be(expectedResult);
}

[Test]
public async Task Get_WhenNoPluginIsLoaded_ShouldNotThrowException()
{
// Arrange
Environment.SetEnvironmentVariable("PLUGINS", " ");
using var factory = new WebApplicationFactory<Program>();
var client = factory.CreateClient();
var requestUri = "/api/Hello";

// Act
var httpResponse = await client.GetAsync(requestUri);

// Assert
httpResponse.StatusCode.Should().Be(HttpStatusCode.OK);
}
}

0 comments on commit 8e98451

Please sign in to comment.