xorm/dialects/table_name_test.go

31 lines
700 B
Go
Raw Normal View History

2018-04-11 05:53:09 +00:00
// Copyright 2018 The Xorm Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package dialects
2018-04-11 05:53:09 +00:00
import (
"testing"
2023-10-27 07:32:38 +00:00
"xorm.io/xorm/v2/names"
2018-04-11 05:53:09 +00:00
"github.com/stretchr/testify/assert"
)
type MCC struct {
ID int64 `xorm:"pk 'id'"`
Code string `xorm:"'code'"`
Description string `xorm:"'description'"`
}
func (mcc *MCC) TableName() string {
return "mcc"
}
func TestFullTableName(t *testing.T) {
dialect := QueryDialect("mysql")
2018-04-11 05:53:09 +00:00
assert.EqualValues(t, "mcc", FullTableName(dialect, names.SnakeMapper{}, &MCC{}))
assert.EqualValues(t, "mcc", FullTableName(dialect, names.SnakeMapper{}, "mcc"))
2018-04-11 05:53:09 +00:00
}