2022-10-17 10:57:49 +00:00
|
|
|
package code_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2023-05-24 11:01:50 +00:00
|
|
|
"git.kmsign.com/royalcat/repogen/internal/code"
|
2022-10-17 10:57:49 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
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())
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|