forked from go-gorm/gorm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate more friendly names for table and columns
- Loading branch information
Showing
2 changed files
with
63 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package gorm_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/jinzhu/gorm" | ||
) | ||
|
||
func TestToDBNameGenerateFriendlyName(t *testing.T) { | ||
var maps = map[string]string{ | ||
"ThisIsATest": "this_is_a_test", | ||
"PFAndESI": "pf_and_esi", | ||
"AbcAndJkl": "abc_and_jkl", | ||
"EmployeeID": "employee_id", | ||
"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)) | ||
} | ||
} | ||
} |