This commit is contained in:
Lunny Xiao 2020-03-10 15:51:02 +08:00
parent 127641244f
commit 7717904fa7
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A
1 changed files with 17 additions and 0 deletions

View File

@ -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)))
}
}