repogen/internal/code/errors_test.go

37 lines
888 B
Go
Raw Normal View History

package code_test
import (
"testing"
2023-05-24 11:04:29 +00:00
"git.kmsign.ru/royalcat/repogen/internal/code"
)
type ErrorTestCase struct {
Name string
Error error
ExpectedString string
}
func TestError(t *testing.T) {
testTable := []ErrorTestCase{
{
Name: "DuplicateStructError",
Error: code.DuplicateStructError("User"),
ExpectedString: "code: duplicate implementation of struct 'User'",
},
{
Name: "DuplicateInterfaceError",
Error: code.DuplicateInterfaceError("UserRepository"),
ExpectedString: "code: duplicate implementation of interface 'UserRepository'",
},
}
for _, testCase := range testTable {
t.Run(testCase.Name, func(t *testing.T) {
if testCase.Error.Error() != testCase.ExpectedString {
t.Errorf("Expected = %+v\nReceived = %+v", testCase.ExpectedString, testCase.Error.Error())
}
})
}
}