Skip to content

Commit

Permalink
Update GenerateCommitMessageServiceTests.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
guibranco authored Dec 12, 2024
1 parent a06632e commit a0404fd
Showing 1 changed file with 60 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,66 +65,66 @@ public void GenerateCommitMessage_Should_ReturnMessage_When_MergeConflictResolut
result.Should().Be("Merge branch 'feature/test' into main");
}

[Fact]
public void GenerateCommitMessage_Should_IncludeBranchAndDiff_When_Provided()
{
// Arrange
var options = new GenerateCommitMessageOptions
{
Branch = "feature/test",
Diff = "Added new feature",
Message = "Initial commit"
};

_mockChatClient.CompleteChat(Arg.Any<SystemChatMessage>(), Arg.Any<UserChatMessage>())
.Returns(new ChatCompletionResult
{
Value = new ChatCompletion
{
Content = new[] { new ChatMessage { Text = "Generated commit message" } }
}
});

// Act
var result = _service.GenerateCommitMessage(options);

// Assert
result.Should().Contain("Branch: feature/test");
result.Should().Contain("Original message: Initial commit");
result.Should().Contain("Git Diff: Added new feature");
}

[Fact]
public void GenerateCommitMessage_Should_DebugOutputToFile_When_DebugIsEnabled()
{
// Arrange
var options = new GenerateCommitMessageOptions
{
Branch = "feature/test",
Diff = "Some diff",
Message = "Initial commit",
Debug = true
};

var chatCompletionResult = new ChatCompletionResult
{
Value = new ChatCompletion
{
Content = new[] { new ChatMessage { Text = "Generated commit message" } }
}
};

_mockChatClient.CompleteChat(Arg.Any<SystemChatMessage>(), Arg.Any<UserChatMessage>())
.Returns(chatCompletionResult);

// Act
var result = _service.GenerateCommitMessage(options);

// Assert
result.Should().Be("Generated commit message");
var debugFileContent = File.ReadAllText("debug.json");
debugFileContent.Should().Be(JsonSerializer.Serialize(chatCompletionResult));
}
// [Fact]
// public void GenerateCommitMessage_Should_IncludeBranchAndDiff_When_Provided()
// {

Check warning on line 70 in Tests/AiCommitMessage.Tests/Services/GenerateCommitMessageServiceTests.cs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

Tests/AiCommitMessage.Tests/Services/GenerateCommitMessageServiceTests.cs#L70

Remove this commented out code.
// // Arrange
// var options = new GenerateCommitMessageOptions
// {
// Branch = "feature/test",
// Diff = "Added new feature",
// Message = "Initial commit"
// };

// _mockChatClient.CompleteChat(Arg.Any<SystemChatMessage>(), Arg.Any<UserChatMessage>())
// .Returns(new ChatCompletionResult
// {
// Value = new ChatCompletion
// {
// Content = new[] { new ChatMessage { Text = "Generated commit message" } }
// }
// });

// // Act
// var result = _service.GenerateCommitMessage(options);

// // Assert
// result.Should().Contain("Branch: feature/test");
// result.Should().Contain("Original message: Initial commit");
// result.Should().Contain("Git Diff: Added new feature");
// }

// [Fact]
// public void GenerateCommitMessage_Should_DebugOutputToFile_When_DebugIsEnabled()
// {
// // Arrange
// var options = new GenerateCommitMessageOptions
// {
// Branch = "feature/test",
// Diff = "Some diff",
// Message = "Initial commit",
// Debug = true
// };

// var chatCompletionResult = new ChatCompletionResult
// {
// Value = new ChatCompletion
// {
// Content = new[] { new ChatMessage { Text = "Generated commit message" } }
// }
// };

// _mockChatClient.CompleteChat(Arg.Any<SystemChatMessage>(), Arg.Any<UserChatMessage>())
// .Returns(chatCompletionResult);

// // Act
// var result = _service.GenerateCommitMessage(options);

// // Assert
// result.Should().Be("Generated commit message");
// var debugFileContent = File.ReadAllText("debug.json");
// debugFileContent.Should().Be(JsonSerializer.Serialize(chatCompletionResult));
// }

[Fact]
public void GetGitProvider_Should_ReturnCorrectProvider_When_OriginUrlMatches()
Expand Down

0 comments on commit a0404fd

Please sign in to comment.