repogen/internal/code/errors_test.go
2023-05-24 14:01:50 +03:00

36 lines
889 B
Go

package code_test
import (
"testing"
"git.kmsign.com/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())
}
})
}
}