Skip to content

Commit 450bfb0

Browse files
author
Piotr Stachaczynski
committed
feat: fix tests
1 parent e7ca900 commit 450bfb0

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/MaIN.Core.UnitTests/ChatContextTests.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,13 @@ public async Task CompleteAsync_ShouldCallChatService()
8282
Content = "test-message"
8383
}
8484
};
85+
86+
8587
_mockChatService.Setup(s => s.Completions(It.IsAny<Chat>(), It.IsAny<bool>(), It.IsAny<bool>(), null))
8688
.ReturnsAsync(chatResult);
8789

90+
_chatContext.WithMessage("User message");
91+
8892
// Act
8993
var result = await _chatContext.CompleteAsync();
9094

src/MaIN.Core/Hub/Contexts/ChatContext.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ public async Task<ChatResult> CompleteAsync(
130130
bool interactive = false,
131131
Func<LLMTokenValue?, Task>? changeOfValue = null)
132132
{
133+
if (_chat.Messages.Count == 0)
134+
{
135+
throw new InvalidOperationException("Chat has no messages."); //TODO good candidate for domain exception
136+
}
133137
_chat.Messages.Last().Files = _files;
134138
if (!await ChatExists(_chat.Id))
135139
{

0 commit comments

Comments
 (0)