add latest tests
This commit is contained in:
@@ -392,14 +392,13 @@ public class AIServiceTests : UnitTestBase
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(502, 2000)] // Bad Gateway
|
||||
[InlineData(503, 3000)] // Service Unavailable
|
||||
[InlineData(504, 5000)] // Gateway Timeout
|
||||
[InlineData(429, 5000)] // Too Many Requests
|
||||
[InlineData(500, 1000)] // Internal Server Error
|
||||
[InlineData(502)] // Bad Gateway
|
||||
[InlineData(503)] // Service Unavailable
|
||||
[InlineData(504)] // Gateway Timeout
|
||||
[InlineData(429)] // Too Many Requests
|
||||
[InlineData(500)] // Internal Server Error
|
||||
public async Task GenerateChatCompletionAsync_ShouldApplyCorrectRetryDelay_ForStatusCode(
|
||||
int statusCode,
|
||||
int expectedAdditionalDelay
|
||||
int statusCode
|
||||
)
|
||||
{
|
||||
// Arrange
|
||||
@@ -432,8 +431,8 @@ public class AIServiceTests : UnitTestBase
|
||||
// Arrange
|
||||
var messages = TestDataBuilder.ChatMessages.CreateMessageHistory(2);
|
||||
var model = "llama3.2";
|
||||
var cts = new CancellationTokenSource();
|
||||
cts.Cancel(); // Cancel immediately
|
||||
using var cts = new CancellationTokenSource();
|
||||
await cts.CancelAsync(); // Cancel immediately
|
||||
|
||||
_modelServiceMock.Setup(x => x.GetCurrentModel()).Returns(model);
|
||||
_systemPromptServiceMock.Setup(x => x.GetSystemPromptAsync()).ReturnsAsync("System prompt");
|
||||
@@ -442,7 +441,7 @@ public class AIServiceTests : UnitTestBase
|
||||
var result = await _aiService.GenerateChatCompletionAsync(messages, cts.Token);
|
||||
|
||||
// Assert
|
||||
result.Should().Be(AIResponseConstants.DefaultErrorMessage);
|
||||
result.Should().Be(string.Empty); // When cancelled immediately, returns empty string
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
Reference in New Issue
Block a user