remove pkg directory;

remove build directory;
remove githook directory;
This commit is contained in:
Ming Deng
2020-10-08 17:17:15 +08:00
parent 034cb3222e
commit 14c1b76569
431 changed files with 372 additions and 545 deletions

View File

@@ -0,0 +1,62 @@
// Copyright 2020
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package orm
import (
"testing"
"github.com/stretchr/testify/assert"
)
type Interface struct {
Id int
Name string
Index1 string
Index2 string
Unique1 string
Unique2 string
}
func (i *Interface) TableIndex() [][]string {
return [][]string{{"index1"}, {"index2"}}
}
func (i *Interface) TableUnique() [][]string {
return [][]string{{"unique1"}, {"unique2"}}
}
func (i *Interface) TableName() string {
return "INTERFACE_"
}
func (i *Interface) TableEngine() string {
return "innodb"
}
func TestDbBase_GetTables(t *testing.T) {
RegisterModel(&Interface{})
mi, ok := modelCache.get("INTERFACE_")
assert.True(t, ok)
assert.NotNil(t, mi)
engine := getTableEngine(mi.addrField)
assert.Equal(t, "innodb", engine)
uniques := getTableUnique(mi.addrField)
assert.Equal(t, [][]string{{"unique1"}, {"unique2"}}, uniques)
indexes := getTableIndex(mi.addrField)
assert.Equal(t, [][]string{{"index1"}, {"index2"}}, indexes)
}