Files
galaxy-game/internal/error/generic_test.go
T
2025-11-21 21:40:15 +03:00

28 lines
682 B
Go

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)
})
}
}