Skip to content

Commit c8ae6fa

Browse files
authored
add test for tablename (go-xorm#885)
1 parent 3ef987a commit c8ae6fa

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

engine_table_test.go

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright 2018 The Xorm Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
package xorm
6+
7+
import (
8+
"testing"
9+
10+
"github.com/stretchr/testify/assert"
11+
)
12+
13+
type MCC struct {
14+
ID int64 `xorm:"pk 'id'"`
15+
Code string `xorm:"'code'"`
16+
Description string `xorm:"'description'"`
17+
}
18+
19+
func (mcc *MCC) TableName() string {
20+
return "mcc"
21+
}
22+
23+
func TestTableName1(t *testing.T) {
24+
assert.NoError(t, prepareEngine())
25+
26+
assert.EqualValues(t, "mcc", testEngine.TableName(new(MCC)))
27+
assert.EqualValues(t, "mcc", testEngine.TableName("mcc"))
28+
}

0 commit comments

Comments
 (0)