2021-05-30 07:22:04 +02:00
|
|
|
package mergeconflicts
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestDetermineLineType(t *testing.T) {
|
|
|
|
type scenario struct {
|
|
|
|
line string
|
|
|
|
expected LineType
|
|
|
|
}
|
|
|
|
|
|
|
|
scenarios := []scenario{
|
|
|
|
{
|
|
|
|
line: "",
|
|
|
|
expected: NOT_A_MARKER,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
line: "blah",
|
|
|
|
expected: NOT_A_MARKER,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
line: "<<<<<<< HEAD",
|
|
|
|
expected: START,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
line: "<<<<<<< HEAD:my_branch",
|
|
|
|
expected: START,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
line: "<<<<<<< MERGE_HEAD:my_branch",
|
|
|
|
expected: START,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
line: "<<<<<<< Updated upstream:my_branch",
|
|
|
|
expected: START,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
line: "<<<<<<< ours:my_branch",
|
|
|
|
expected: START,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
line: "=======",
|
2021-08-21 18:03:05 +02:00
|
|
|
expected: TARGET,
|
2021-05-30 07:22:04 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
line: ">>>>>>> blah",
|
|
|
|
expected: END,
|
|
|
|
},
|
2021-08-21 18:03:05 +02:00
|
|
|
{
|
|
|
|
line: "||||||| adf33b9",
|
|
|
|
expected: ANCESTOR,
|
|
|
|
},
|
2021-05-30 07:22:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
for _, s := range scenarios {
|
|
|
|
assert.EqualValues(t, s.expected, determineLineType(s.line))
|
|
|
|
}
|
|
|
|
}
|