Initial cloud-services repo - gateway service + pkg modules

This commit is contained in:
Chris Rai
2026-01-30 23:14:52 -05:00
commit fbb820d7b3
1037 changed files with 171318 additions and 0 deletions

55
pkg/validator/ecu_test.go Normal file
View File

@@ -0,0 +1,55 @@
package validator_test
import (
"testing"
"fiskerinc.com/modules/testhelper"
"fiskerinc.com/modules/validator"
)
type TestECU struct {
Name string `validate:"ecu"`
Expected string
}
var ecuValidTests = []TestECU{
{Name: "BCM"},
{Name: "TBOX"},
{Name: "iBooster"},
}
func TestValidateECU(t *testing.T) {
var tests = []TestECU{
{
Name: "",
Expected: "Key: 'TestECU.Name' Error:Field validation for 'Name' failed on the 'ecu' tag",
},
{
Name: "-",
Expected: "Key: 'TestECU.Name' Error:Field validation for 'Name' failed on the 'ecu' tag",
},
{
Name: "-123",
Expected: "Key: 'TestECU.Name' Error:Field validation for 'Name' failed on the 'ecu' tag",
},
{
Name: "abc",
Expected: "Key: 'TestECU.Name' Error:Field validation for 'Name' failed on the 'ecu' tag",
},
{
Name: "ab12",
Expected: "Key: 'TestECU.Name' Error:Field validation for 'Name' failed on the 'ecu' tag",
},
}
tests = append(tests, ecuValidTests...)
for _, test := range tests {
err := validator.ValidateStruct(test)
if err == nil && test.Expected != "" {
t.Errorf(testhelper.TestErrorTemplate, test.Name, test.Expected, err)
} else if err != nil && err.Error() != test.Expected {
t.Errorf(testhelper.TestErrorTemplate, test.Name, test.Expected, err.Error())
}
}
}