2016-01-10 17:56:22 +03:00
|
|
|
package gorm_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/jinzhu/gorm"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestToDBNameGenerateFriendlyName(t *testing.T) {
|
|
|
|
var maps = map[string]string{
|
2016-01-16 04:40:13 +03:00
|
|
|
"": "",
|
2017-03-30 05:48:50 +03:00
|
|
|
"X": "x",
|
2016-01-10 17:56:22 +03:00
|
|
|
"ThisIsATest": "this_is_a_test",
|
|
|
|
"PFAndESI": "pf_and_esi",
|
|
|
|
"AbcAndJkl": "abc_and_jkl",
|
|
|
|
"EmployeeID": "employee_id",
|
2016-02-20 17:26:41 +03:00
|
|
|
"SKU_ID": "sku_id",
|
2018-06-25 08:07:53 +03:00
|
|
|
"UTF8": "utf8",
|
|
|
|
"Level1": "level1",
|
|
|
|
"SHA256Hash": "sha256_hash",
|
2017-03-30 05:48:50 +03:00
|
|
|
"FieldX": "field_x",
|
2016-01-10 17:56:22 +03:00
|
|
|
"HTTPAndSMTP": "http_and_smtp",
|
|
|
|
"HTTPServerHandlerForURLID": "http_server_handler_for_url_id",
|
|
|
|
"UUID": "uuid",
|
|
|
|
"HTTPURL": "http_url",
|
|
|
|
"HTTP_URL": "http_url",
|
|
|
|
"ThisIsActuallyATestSoWeMayBeAbleToUseThisCodeInGormPackageAlsoIdCanBeUsedAtTheEndAsID": "this_is_actually_a_test_so_we_may_be_able_to_use_this_code_in_gorm_package_also_id_can_be_used_at_the_end_as_id",
|
|
|
|
}
|
|
|
|
|
|
|
|
for key, value := range maps {
|
|
|
|
if gorm.ToDBName(key) != value {
|
|
|
|
t.Errorf("%v ToDBName should equal %v, but got %v", key, value, gorm.ToDBName(key))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|