add initial git support

This commit is contained in:
Kujtim Hoxha
2025-04-12 18:45:36 +02:00
parent 0697dcc1d9
commit bd2ec29b65
19 changed files with 791 additions and 176 deletions

View File

@@ -459,51 +459,3 @@ func TestEditTool_Run(t *testing.T) {
assert.Equal(t, initialContent, string(fileContent))
})
}
func TestGenerateDiff(t *testing.T) {
testCases := []struct {
name string
oldContent string
newContent string
expectedDiff string
}{
{
name: "add content",
oldContent: "Line 1\nLine 2\n",
newContent: "Line 1\nLine 2\nLine 3\n",
expectedDiff: "Changes:\n Line 1\n Line 2\n+ Line 3\n",
},
{
name: "remove content",
oldContent: "Line 1\nLine 2\nLine 3\n",
newContent: "Line 1\nLine 3\n",
expectedDiff: "Changes:\n Line 1\n- Line 2\n Line 3\n",
},
{
name: "replace content",
oldContent: "Line 1\nLine 2\nLine 3\n",
newContent: "Line 1\nModified Line\nLine 3\n",
expectedDiff: "Changes:\n Line 1\n- Line 2\n+ Modified Line\n Line 3\n",
},
{
name: "empty to content",
oldContent: "",
newContent: "Line 1\nLine 2\n",
expectedDiff: "Changes:\n+ Line 1\n+ Line 2\n",
},
{
name: "content to empty",
oldContent: "Line 1\nLine 2\n",
newContent: "",
expectedDiff: "Changes:\n- Line 1\n- Line 2\n",
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
diff := GenerateDiff(tc.oldContent, tc.newContent)
assert.Contains(t, diff, tc.expectedDiff)
})
}
}