summaryrefslogtreecommitdiff
path: root/workhorse/internal/lsif_transformer/parser/errors_test.go
blob: 31a7130d05e92c0b4e76c2c6ef3a804bb46c744a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package parser

import (
	"errors"
	"testing"

	"github.com/stretchr/testify/require"
)

type customErr struct {
	err string
}

func (e customErr) Error() string {
	return e.err
}

func TestCombineErrors(t *testing.T) {
	err := combineErrors(nil, errors.New("first"), nil, customErr{"second"})
	require.EqualError(t, err, "first\nsecond")

	err = customErr{"custom error"}
	require.Equal(t, err, combineErrors(nil, err, nil))

	require.Nil(t, combineErrors(nil, nil, nil))
}