mirror of
https://github.com/aljazceru/opencode.git
synced 2025-12-21 09:44:21 +01:00
add initial git support
This commit is contained in:
@@ -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)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user