From dd34b633ca109267721398b5a92ad30690d0c3c5 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Wed, 11 Apr 2018 13:03:04 +0800 Subject: [PATCH] add test for tablename --- engine_table_test.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 engine_table_test.go diff --git a/engine_table_test.go b/engine_table_test.go new file mode 100644 index 00000000..8f2300aa --- /dev/null +++ b/engine_table_test.go @@ -0,0 +1,28 @@ +// 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 xorm + +import ( + "testing" + + "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 TestTableName1(t *testing.T) { + assert.NoError(t, prepareEngine()) + + assert.EqualValues(t, "mcc", testEngine.TableName(new(MCC))) + assert.EqualValues(t, "mcc", testEngine.TableName("mcc")) +} -- 2.40.1