|
@@ -31,174 +31,174 @@ type SqlMappingTagStruct struct {
|
|
|
|
|
|
func (s SqlMappingTagStruct) checkFields(t *testing.T, fields []sql_mapping.Field) {
|
|
|
if len(fields) != reflect.TypeOf(s).NumField()-1 {
|
|
|
- t.Fatalf("%+v", errors.Errorf("有字段没有被解析"))
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("有字段没有被解析"))
|
|
|
}
|
|
|
|
|
|
for _, field := range fields {
|
|
|
if field.FieldName == "Ignore" || field.ColumnName == "ignore" {
|
|
|
- t.Fatalf("%+v", errors.Errorf("忽略字段没有被忽略"))
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("忽略字段没有被忽略"))
|
|
|
}
|
|
|
|
|
|
switch field.FieldName {
|
|
|
case "Column":
|
|
|
if s.Column != field.Value {
|
|
|
- t.Fatalf("%+v", errors.Errorf("值不正确: fieldName: %v, fieldValue %v, tagValue %v",
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("值不正确: fieldName: %v, fieldValue %v, tagValue %v",
|
|
|
field.FieldName, s.Column, field.Value))
|
|
|
}
|
|
|
|
|
|
if field.ColumnName != "test_column" {
|
|
|
- t.Fatalf("%+v", errors.Errorf("列名解析测试错误: fieldName: %v, actual columnName: %v",
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual columnName: %v",
|
|
|
field.FieldName, field.ColumnName))
|
|
|
}
|
|
|
case "Key":
|
|
|
if field.ColumnName != "key" {
|
|
|
- t.Fatalf("%+v", errors.Errorf("列名解析测试错误: fieldName: %v, actual columnName: %v",
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual columnName: %v",
|
|
|
field.FieldName, field.ColumnName))
|
|
|
}
|
|
|
|
|
|
if s.Key != field.Value {
|
|
|
- t.Fatalf("%+v", errors.Errorf("值不正确: fieldName: %v, fieldValue %v, tagValue %v",
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("值不正确: fieldName: %v, fieldValue %v, tagValue %v",
|
|
|
field.FieldName, s.Key, field.Value))
|
|
|
}
|
|
|
|
|
|
if !field.IsKey {
|
|
|
- t.Fatalf("%+v", errors.Errorf("key解析错误"))
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("key解析错误"))
|
|
|
}
|
|
|
case "NotUpdate":
|
|
|
if field.ColumnName != "not_update" {
|
|
|
- t.Fatalf("%+v", errors.Errorf("列名解析测试错误: fieldName: %v, actual columnName: %v",
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual columnName: %v",
|
|
|
field.FieldName, field.ColumnName))
|
|
|
}
|
|
|
|
|
|
if s.NotUpdate != field.Value {
|
|
|
- t.Fatalf("%+v", errors.Errorf("值不正确:fieldName: %v, fieldValue %v, tagValue %v",
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("值不正确:fieldName: %v, fieldValue %v, tagValue %v",
|
|
|
field.FieldName, s.NotUpdate, field.Value))
|
|
|
}
|
|
|
|
|
|
if field.CanUpdate {
|
|
|
- t.Fatalf("%+v", errors.Errorf("notUpdate解析错误"))
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("notUpdate解析错误"))
|
|
|
}
|
|
|
case "UpdateClear":
|
|
|
if field.ColumnName != "update_clear" {
|
|
|
- t.Fatalf("%+v", errors.Errorf("列名解析测试错误: fieldName: %v, actual columnName: %v",
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual columnName: %v",
|
|
|
field.FieldName, field.ColumnName))
|
|
|
}
|
|
|
|
|
|
if s.UpdateClear != field.Value {
|
|
|
- t.Fatalf("%+v", errors.Errorf("值不正确:fieldName: %v, fieldValue %v, tagValue %v",
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("值不正确:fieldName: %v, fieldValue %v, tagValue %v",
|
|
|
field.FieldName, s.UpdateClear, field.Value))
|
|
|
}
|
|
|
|
|
|
if !field.CanUpdateClear {
|
|
|
- t.Fatalf("%+v", errors.Errorf("updateClear解析错误"))
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("updateClear解析错误"))
|
|
|
}
|
|
|
case "Aes":
|
|
|
if field.ColumnName != "aes" {
|
|
|
- t.Fatalf("%+v", errors.Errorf("列名解析测试错误: fieldName: %v, actual columnName: %v",
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual columnName: %v",
|
|
|
field.FieldName, field.ColumnName))
|
|
|
}
|
|
|
|
|
|
encrypted, err := encoding.AESEncrypt(s.Aes, "@MKU^*HF%p%G43Fd)UAHCVD#$XZSWQ@L")
|
|
|
if err != nil {
|
|
|
- t.Fatalf("%+v", errors.Errorf(err.Error()))
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf(err.Error()))
|
|
|
}
|
|
|
|
|
|
if encrypted != field.Value {
|
|
|
- t.Fatalf("%+v", errors.Errorf("值不正确:fieldName: %v, fieldValue %v, tagValue %v",
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("值不正确:fieldName: %v, fieldValue %v, tagValue %v",
|
|
|
field.FieldName, encrypted, field.Value))
|
|
|
}
|
|
|
case "JoinWith":
|
|
|
if field.ColumnName != "join_with" {
|
|
|
- t.Fatalf("%+v", errors.Errorf("列名解析测试错误: fieldName: %v, actual columnName: %v",
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual columnName: %v",
|
|
|
field.FieldName, field.ColumnName))
|
|
|
}
|
|
|
|
|
|
if strings.Join(s.JoinWith, "##") != field.Value {
|
|
|
- t.Fatalf("%+v", errors.Errorf("值不正确: fieldName: %v, fieldValue %v, tagValue %v",
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("值不正确: fieldName: %v, fieldValue %v, tagValue %v",
|
|
|
field.FieldName, strings.Join(s.JoinWith, "##"), field.Value))
|
|
|
}
|
|
|
case "Trim":
|
|
|
if field.ColumnName != "trim" {
|
|
|
- t.Fatalf("%+v", errors.Errorf("列名解析测试错误: fieldName: %v, actual columnName: %v",
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual columnName: %v",
|
|
|
field.FieldName, field.ColumnName))
|
|
|
}
|
|
|
|
|
|
if strings.Trim(s.Trim, "||") != field.Value {
|
|
|
- t.Fatalf("%+v", errors.Errorf("值不正确:fieldName: %v, fieldValue %v, tagValue %v",
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("值不正确:fieldName: %v, fieldValue %v, tagValue %v",
|
|
|
field.FieldName, strings.Trim(s.Trim, "||"), field.Value))
|
|
|
}
|
|
|
case "TrimPrefix":
|
|
|
if field.ColumnName != "trim_prefix" {
|
|
|
- t.Fatalf("%+v", errors.Errorf("列名解析测试错误: fieldName: %v, actual columnName: %v",
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual columnName: %v",
|
|
|
field.FieldName, field.ColumnName))
|
|
|
}
|
|
|
|
|
|
if strings.TrimPrefix(s.TrimPrefix, "{{") != field.Value {
|
|
|
- t.Fatalf("%+v", errors.Errorf("值不正确:fieldName: %v, fieldValue %v, tagValue %v",
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("值不正确:fieldName: %v, fieldValue %v, tagValue %v",
|
|
|
field.FieldName, strings.TrimPrefix(s.TrimPrefix, "{{"), field.Value))
|
|
|
}
|
|
|
case "TrimSuffix":
|
|
|
if field.ColumnName != "trim_suffix" {
|
|
|
- t.Fatalf("%+v", errors.Errorf("列名解析测试错误: fieldName: %v, actual columnName: %v",
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual columnName: %v",
|
|
|
field.FieldName, field.ColumnName))
|
|
|
}
|
|
|
|
|
|
if strings.TrimSuffix(s.TrimSuffix, "}}") != field.Value {
|
|
|
- t.Fatalf("%+v", errors.Errorf("值不正确:fieldName: %v, fieldValue %v, tagValue %v",
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("值不正确:fieldName: %v, fieldValue %v, tagValue %v",
|
|
|
field.FieldName, strings.TrimSuffix(s.TrimPrefix, "}}"), field.Value))
|
|
|
}
|
|
|
case "WrongAes":
|
|
|
if field.ColumnName != "wrong_aes" {
|
|
|
- t.Fatalf("%+v", errors.Errorf("列名解析测试错误: fieldName: %v, actual columnName: %v",
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual columnName: %v",
|
|
|
field.FieldName, field.ColumnName))
|
|
|
}
|
|
|
|
|
|
if s.WrongAes != field.Value {
|
|
|
- t.Fatalf("%+v", errors.Errorf("值不正确:fieldName: %v, fieldValue %v, tagValue %v",
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("值不正确:fieldName: %v, fieldValue %v, tagValue %v",
|
|
|
field.FieldName, s.WrongAes, field.Value))
|
|
|
}
|
|
|
case "WrongJoinWith":
|
|
|
if field.ColumnName != "wrong_join_with" {
|
|
|
- t.Fatalf("%+v", errors.Errorf("列名解析测试错误: fieldName: %v, actual columnName: %v",
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual columnName: %v",
|
|
|
field.FieldName, field.ColumnName))
|
|
|
}
|
|
|
|
|
|
if s.WrongJoinWith != field.Value {
|
|
|
- t.Fatalf("%+v", errors.Errorf("值不正确:fieldName: %v, fieldValue %v, tagValue %v",
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("值不正确:fieldName: %v, fieldValue %v, tagValue %v",
|
|
|
field.FieldName, s.WrongJoinWith, field.Value))
|
|
|
}
|
|
|
case "WrongTrim":
|
|
|
if field.ColumnName != "wrong_trim" {
|
|
|
- t.Fatalf("%+v", errors.Errorf("列名解析测试错误: fieldName: %v, actual columnName: %v",
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual columnName: %v",
|
|
|
field.FieldName, field.ColumnName))
|
|
|
}
|
|
|
|
|
|
if s.WrongTrim != field.Value {
|
|
|
- t.Fatalf("%+v", errors.Errorf("值不正确:fieldName: %v, fieldValue %v, tagValue %v",
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("值不正确:fieldName: %v, fieldValue %v, tagValue %v",
|
|
|
field.FieldName, s.WrongTrim, field.Value))
|
|
|
}
|
|
|
case "WrongTrimPrefix":
|
|
|
if field.ColumnName != "wrong_trim_prefix" {
|
|
|
- t.Fatalf("%+v", errors.Errorf("列名解析测试错误: fieldName: %v, actual columnName: %v",
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual columnName: %v",
|
|
|
field.FieldName, field.ColumnName))
|
|
|
}
|
|
|
|
|
|
if s.WrongTrimPrefix != field.Value {
|
|
|
- t.Fatalf("%+v", errors.Errorf("值不正确:fieldName: %v, fieldValue %v, tagValue %v",
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("值不正确:fieldName: %v, fieldValue %v, tagValue %v",
|
|
|
field.FieldName, s.WrongTrimPrefix, field.Value))
|
|
|
}
|
|
|
case "WrongTrimSuffix":
|
|
|
if field.ColumnName != "wrong_trim_suffix" {
|
|
|
- t.Fatalf("%+v", errors.Errorf("列名解析测试错误: fieldName: %v, actual columnName: %v",
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual columnName: %v",
|
|
|
field.FieldName, field.ColumnName))
|
|
|
}
|
|
|
|
|
|
if s.WrongTrimSuffix != field.Value {
|
|
|
- t.Fatalf("%+v", errors.Errorf("值不正确:fieldName: %v, fieldValue %v, tagValue %v",
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("值不正确:fieldName: %v, fieldValue %v, tagValue %v",
|
|
|
field.FieldName, s.WrongTrimPrefix, field.Value))
|
|
|
}
|
|
|
default:
|
|
|
- t.Fatalf("%+v", errors.Errorf("未知的字段名: tag fieldName: %v", field.FieldName))
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("未知的字段名: tag fieldName: %v", field.FieldName))
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -224,169 +224,169 @@ type SqlMappingTagPointerFieldsStruct struct {
|
|
|
func (s SqlMappingTagPointerFieldsStruct) checkFields(t *testing.T, fields []sql_mapping.Field) {
|
|
|
for _, field := range fields {
|
|
|
if field.FieldName == "Ignore" || field.ColumnName == "ignore" {
|
|
|
- t.Fatalf("%+v", errors.Errorf("忽略字段没有被忽略"))
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("忽略字段没有被忽略"))
|
|
|
}
|
|
|
|
|
|
switch field.FieldName {
|
|
|
case "Column":
|
|
|
if *s.Column != field.Value {
|
|
|
- t.Fatalf("%+v", errors.Errorf("值不正确:fieldName: %v, fieldValue %v, tagValue %v",
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("值不正确:fieldName: %v, fieldValue %v, tagValue %v",
|
|
|
field.FieldName, s.Column, field.Value))
|
|
|
}
|
|
|
|
|
|
if field.ColumnName != "test_column" {
|
|
|
- t.Fatalf("%+v", errors.Errorf("列名解析测试错误: fieldName: %v, actual columnName: %v",
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual columnName: %v",
|
|
|
field.FieldName, field.ColumnName))
|
|
|
}
|
|
|
case "Key":
|
|
|
if field.ColumnName != "key" {
|
|
|
- t.Fatalf("%+v", errors.Errorf("列名解析测试错误: fieldName: %v, actual columnName: %v",
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual columnName: %v",
|
|
|
field.FieldName, field.ColumnName))
|
|
|
}
|
|
|
|
|
|
if *s.Key != field.Value {
|
|
|
- t.Fatalf("%+v", errors.Errorf("值不正确: fieldName: %v, fieldValue %v, tagValue %v",
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("值不正确: fieldName: %v, fieldValue %v, tagValue %v",
|
|
|
field.FieldName, s.Key, field.Value))
|
|
|
}
|
|
|
|
|
|
if !field.IsKey {
|
|
|
- t.Fatalf("%+v", errors.Errorf("key解析错误"))
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("key解析错误"))
|
|
|
}
|
|
|
case "NotUpdate":
|
|
|
if field.ColumnName != "not_update" {
|
|
|
- t.Fatalf("%+v", errors.Errorf("列名解析测试错误: fieldName: %v, actual columnName: %v",
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual columnName: %v",
|
|
|
field.FieldName, field.ColumnName))
|
|
|
}
|
|
|
|
|
|
if *s.NotUpdate != field.Value {
|
|
|
- t.Fatalf("%+v", errors.Errorf("值不正确:fieldName: %v, fieldValue %v, tagValue %v",
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("值不正确:fieldName: %v, fieldValue %v, tagValue %v",
|
|
|
field.FieldName, s.NotUpdate, field.Value))
|
|
|
}
|
|
|
|
|
|
if field.CanUpdate {
|
|
|
- t.Fatalf("%+v", errors.Errorf("notUpdate解析错误"))
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("notUpdate解析错误"))
|
|
|
}
|
|
|
case "UpdateClear":
|
|
|
if field.ColumnName != "update_clear" {
|
|
|
- t.Fatalf("%+v", errors.Errorf("列名解析测试错误: fieldName: %v, actual columnName: %v",
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual columnName: %v",
|
|
|
field.FieldName, field.ColumnName))
|
|
|
}
|
|
|
|
|
|
if *s.UpdateClear != field.Value {
|
|
|
- t.Fatalf("%+v", errors.Errorf("值不正确:fieldName: %v, fieldValue %v, tagValue %v",
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("值不正确:fieldName: %v, fieldValue %v, tagValue %v",
|
|
|
field.FieldName, s.UpdateClear, field.Value))
|
|
|
}
|
|
|
|
|
|
if !field.CanUpdateClear {
|
|
|
- t.Fatalf("%+v", errors.Errorf("updateClear解析错误"))
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("updateClear解析错误"))
|
|
|
}
|
|
|
case "Aes":
|
|
|
if field.ColumnName != "aes" {
|
|
|
- t.Fatalf("%+v", errors.Errorf("列名解析测试错误: fieldName: %v, actual columnName: %v",
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual columnName: %v",
|
|
|
field.FieldName, field.ColumnName))
|
|
|
}
|
|
|
|
|
|
encrypted, err := encoding.AESEncrypt(*s.Aes, "@MKU^*HF%p%G43Fd)UAHCVD#$XZSWQ@L")
|
|
|
if err != nil {
|
|
|
- t.Fatalf("%+v", errors.Errorf(err.Error()))
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf(err.Error()))
|
|
|
}
|
|
|
|
|
|
if encrypted != field.Value {
|
|
|
- t.Fatalf("%+v", errors.Errorf("值不正确:fieldName: %v, fieldValue %v, tagValue %v",
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("值不正确:fieldName: %v, fieldValue %v, tagValue %v",
|
|
|
field.FieldName, encrypted, field.Value))
|
|
|
}
|
|
|
case "JoinWith":
|
|
|
if field.ColumnName != "join_with" {
|
|
|
- t.Fatalf("%+v", errors.Errorf("列名解析测试错误: fieldName: %v, actual columnName: %v",
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual columnName: %v",
|
|
|
field.FieldName, field.ColumnName))
|
|
|
}
|
|
|
|
|
|
if strings.Join(*s.JoinWith, "##") != field.Value {
|
|
|
- t.Fatalf("%+v", errors.Errorf("值不正确: fieldName: %v, fieldValue %v, tagValue %v",
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("值不正确: fieldName: %v, fieldValue %v, tagValue %v",
|
|
|
field.FieldName, strings.Join(*s.JoinWith, "##"), field.Value))
|
|
|
}
|
|
|
case "Trim":
|
|
|
if field.ColumnName != "trim" {
|
|
|
- t.Fatalf("%+v", errors.Errorf("列名解析测试错误: fieldName: %v, actual columnName: %v",
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual columnName: %v",
|
|
|
field.FieldName, field.ColumnName))
|
|
|
}
|
|
|
|
|
|
if strings.Trim(*s.Trim, "||") != field.Value {
|
|
|
- t.Fatalf("%+v", errors.Errorf("值不正确:fieldName: %v, fieldValue %v, tagValue %v",
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("值不正确:fieldName: %v, fieldValue %v, tagValue %v",
|
|
|
field.FieldName, strings.Trim(*s.Trim, "||"), field.Value))
|
|
|
}
|
|
|
case "TrimPrefix":
|
|
|
if field.ColumnName != "trim_prefix" {
|
|
|
- t.Fatalf("%+v", errors.Errorf("列名解析测试错误: fieldName: %v, actual columnName: %v",
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual columnName: %v",
|
|
|
field.FieldName, field.ColumnName))
|
|
|
}
|
|
|
|
|
|
if strings.TrimPrefix(*s.TrimPrefix, "{{") != field.Value {
|
|
|
- t.Fatalf("%+v", errors.Errorf("值不正确:fieldName: %v, fieldValue %v, tagValue %v",
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("值不正确:fieldName: %v, fieldValue %v, tagValue %v",
|
|
|
field.FieldName, strings.TrimPrefix(*s.TrimPrefix, "{{"), field.Value))
|
|
|
}
|
|
|
case "TrimSuffix":
|
|
|
if field.ColumnName != "trim_suffix" {
|
|
|
- t.Fatalf("%+v", errors.Errorf("列名解析测试错误: fieldName: %v, actual columnName: %v",
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual columnName: %v",
|
|
|
field.FieldName, field.ColumnName))
|
|
|
}
|
|
|
|
|
|
if strings.TrimSuffix(*s.TrimSuffix, "}}") != field.Value {
|
|
|
- t.Fatalf("%+v", errors.Errorf("值不正确:fieldName: %v, fieldValue %v, tagValue %v",
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("值不正确:fieldName: %v, fieldValue %v, tagValue %v",
|
|
|
field.FieldName, strings.TrimSuffix(*s.TrimPrefix, "}}"), field.Value))
|
|
|
}
|
|
|
case "WrongAes":
|
|
|
if field.ColumnName != "wrong_aes" {
|
|
|
- t.Fatalf("%+v", errors.Errorf("列名解析测试错误: fieldName: %v, actual columnName: %v",
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual columnName: %v",
|
|
|
field.FieldName, field.ColumnName))
|
|
|
}
|
|
|
|
|
|
if *s.WrongAes != field.Value {
|
|
|
- t.Fatalf("%+v", errors.Errorf("值不正确:fieldName: %v, fieldValue %v, tagValue %v",
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("值不正确:fieldName: %v, fieldValue %v, tagValue %v",
|
|
|
field.FieldName, s.WrongAes, field.Value))
|
|
|
}
|
|
|
case "WrongJoinWith":
|
|
|
if field.ColumnName != "wrong_join_with" {
|
|
|
- t.Fatalf("%+v", errors.Errorf("列名解析测试错误: fieldName: %v, actual columnName: %v",
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual columnName: %v",
|
|
|
field.FieldName, field.ColumnName))
|
|
|
}
|
|
|
|
|
|
if *s.WrongJoinWith != field.Value {
|
|
|
- t.Fatalf("%+v", errors.Errorf("值不正确:fieldName: %v, fieldValue %v, tagValue %v",
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("值不正确:fieldName: %v, fieldValue %v, tagValue %v",
|
|
|
field.FieldName, s.WrongJoinWith, field.Value))
|
|
|
}
|
|
|
case "WrongTrim":
|
|
|
if field.ColumnName != "wrong_trim" {
|
|
|
- t.Fatalf("%+v", errors.Errorf("列名解析测试错误: fieldName: %v, actual columnName: %v",
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual columnName: %v",
|
|
|
field.FieldName, field.ColumnName))
|
|
|
}
|
|
|
|
|
|
if *s.WrongTrim != field.Value {
|
|
|
- t.Fatalf("%+v", errors.Errorf("值不正确:fieldName: %v, fieldValue %v, tagValue %v",
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("值不正确:fieldName: %v, fieldValue %v, tagValue %v",
|
|
|
field.FieldName, s.WrongTrim, field.Value))
|
|
|
}
|
|
|
case "WrongTrimPrefix":
|
|
|
if field.ColumnName != "wrong_trim_prefix" {
|
|
|
- t.Fatalf("%+v", errors.Errorf("列名解析测试错误: fieldName: %v, actual columnName: %v",
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual columnName: %v",
|
|
|
field.FieldName, field.ColumnName))
|
|
|
}
|
|
|
|
|
|
if *s.WrongTrimPrefix != field.Value {
|
|
|
- t.Fatalf("%+v", errors.Errorf("值不正确:fieldName: %v, fieldValue %v, tagValue %v",
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("值不正确:fieldName: %v, fieldValue %v, tagValue %v",
|
|
|
field.FieldName, s.WrongTrimPrefix, field.Value))
|
|
|
}
|
|
|
case "WrongTrimSuffix":
|
|
|
if field.ColumnName != "wrong_trim_suffix" {
|
|
|
- t.Fatalf("%+v", errors.Errorf("列名解析测试错误: fieldName: %v, actual columnName: %v",
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("列名解析测试错误: fieldName: %v, actual columnName: %v",
|
|
|
field.FieldName, field.ColumnName))
|
|
|
}
|
|
|
|
|
|
if *s.WrongTrimSuffix != field.Value {
|
|
|
- t.Fatalf("%+v", errors.Errorf("值不正确:fieldName: %v, fieldValue %v, tagValue %v",
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("值不正确:fieldName: %v, fieldValue %v, tagValue %v",
|
|
|
field.FieldName, s.WrongTrimPrefix, field.Value))
|
|
|
}
|
|
|
default:
|
|
|
- t.Fatalf("%+v", errors.Errorf("未知的字段名: tag fieldName: %v", field.FieldName))
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("未知的字段名: tag fieldName: %v", field.FieldName))
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -448,40 +448,40 @@ func TestSqlMappingTagDefaultUsage(t *testing.T) {
|
|
|
|
|
|
fields, err := sql_mapping.DefaultUsage(s)
|
|
|
if err != nil {
|
|
|
- t.Fatalf("%+v", err)
|
|
|
+ t.Fatalf("%+v\n", err)
|
|
|
}
|
|
|
|
|
|
s.checkFields(t, fields)
|
|
|
|
|
|
fields, err = sql_mapping.DefaultUsage(&s)
|
|
|
if err != nil {
|
|
|
- t.Fatalf("%+v", err)
|
|
|
+ t.Fatalf("%+v\n", err)
|
|
|
}
|
|
|
|
|
|
s.checkFields(t, fields)
|
|
|
|
|
|
fields, err = sql_mapping.DefaultUsage(sPointerFields)
|
|
|
if err != nil {
|
|
|
- t.Fatalf("%+v", err)
|
|
|
+ t.Fatalf("%+v\n", err)
|
|
|
}
|
|
|
|
|
|
sPointerFields.checkFields(t, fields)
|
|
|
|
|
|
fields, err = sql_mapping.DefaultUsage(&sPointerFields)
|
|
|
if err != nil {
|
|
|
- t.Fatalf("%+v", err)
|
|
|
+ t.Fatalf("%+v\n", err)
|
|
|
}
|
|
|
|
|
|
sPointerFields.checkFields(t, fields)
|
|
|
|
|
|
fields, err = sql_mapping.DefaultUsage(sPointerFieldsNil)
|
|
|
if err == nil || err.Error() != "无法设置值,请检查是否传递的是非指针结构变量且字段为nil" {
|
|
|
- t.Fatalf("%+v", errors.Errorf("没有检测出from如果有nil字段,必须使用指针结构变量"))
|
|
|
+ t.Fatalf("%+v\n", errors.Errorf("没有检测出from如果有nil字段,必须使用指针结构变量"))
|
|
|
}
|
|
|
|
|
|
fields, err = sql_mapping.DefaultUsage(&sPointerFieldsNil)
|
|
|
if err != nil {
|
|
|
- t.Fatalf("%+v", err)
|
|
|
+ t.Fatalf("%+v\n", err)
|
|
|
}
|
|
|
|
|
|
sPointerFieldsNil.checkFields(t, fields)
|