package error

import (
	"errors"
	"strconv"
	"testing"

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

func TestNewGenericError(t *testing.T) {
	for i, tc := range []struct {
		arg     []any
		message string
	}{
		{arg: []any{"Foo"}, message: "Dummy: Foo"},
		{arg: []any{"Foo%s", "Bar"}, message: "Dummy: FooBar"},
		{arg: []any{errors.New("Error")}, message: "Dummy: Error"},
		{arg: []any{errors.New("Error"), "Foo"}, message: "Dummy: Foo: Error"},
		{arg: []any{errors.New("Error"), "Foo%s", "Bar"}, message: "Dummy: FooBar: Error"},
	} {
		t.Run(strconv.Itoa(i), func(t *testing.T) {
			err := newGenericError(ErrDummy, tc.arg...)
			assert.EqualError(t, err, tc.message)
		})
	}
}
