From 7717904fa75d2b6da2bd2270edbd3d1139ff4ff3 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Tue, 10 Mar 2020 15:51:02 +0800 Subject: [PATCH] add test --- names/table_name_test.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/names/table_name_test.go b/names/table_name_test.go index 994ef80d..76da4135 100644 --- a/names/table_name_test.go +++ b/names/table_name_test.go @@ -5,6 +5,7 @@ package names import ( + "fmt" "reflect" "testing" "time" @@ -121,3 +122,19 @@ func TestGonicMapperCustomTable(t *testing.T) { assert.EqualValues(t, "oauth2_application", GetTableName(LintGonicMapper, reflect.ValueOf(OAuth2Application{}))) } + +type MyTable struct { + Idx int +} + +func (t *MyTable) TableName() string { + return fmt.Sprintf("mytable_%d", t.Idx) +} + +func TestMyTable(t *testing.T) { + var table MyTable + for i := 0; i < 10; i++ { + table.Idx = i + assert.EqualValues(t, fmt.Sprintf("mytable_%d", i), GetTableName(SameMapper{}, reflect.ValueOf(&table))) + } +}