feat(adapter): registry with detect filtering and duplicate guard

This commit is contained in:
2026-05-23 02:48:31 +01:00
parent 6ab8d149e1
commit 95962bdf9a
12 changed files with 389 additions and 0 deletions
+42
View File
@@ -0,0 +1,42 @@
package merge
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestCleanFastForward(t *testing.T) {
res, err := ThreeWay(Inputs{
Base: []byte("a\nb\nc\n"),
Ours: []byte("a\nb\nc\nd\n"),
Theirs: []byte("a\nb\nc\n"),
})
require.NoError(t, err)
assert.False(t, res.Conflict)
assert.Equal(t, "a\nb\nc\nd\n", string(res.Body))
}
func TestConflict(t *testing.T) {
res, err := ThreeWay(Inputs{
Base: []byte("a\n"),
Ours: []byte("a\nours\n"),
Theirs: []byte("a\ntheirs\n"),
})
require.NoError(t, err)
assert.True(t, res.Conflict)
assert.Contains(t, string(res.Body), "<<<<<<<")
assert.Contains(t, string(res.Body), ">>>>>>>")
}
func TestNoOpWhenAllEqual(t *testing.T) {
res, err := ThreeWay(Inputs{
Base: []byte("a\n"),
Ours: []byte("a\n"),
Theirs: []byte("a\n"),
})
require.NoError(t, err)
assert.False(t, res.Conflict)
assert.Equal(t, "a\n", string(res.Body))
}