46 lines
927 B
Go
46 lines
927 B
Go
package lib
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"git.ymnuktech.ru/ymnuk/yt-gen-app/structs"
|
|
)
|
|
|
|
func TestFieldType(t *testing.T) {
|
|
if fieldDBName(&structs.Field{Name: "Field"}) != "field" {
|
|
t.Fail()
|
|
}
|
|
if fieldDBName(&structs.Field{Name: "Field_NAME"}) != "field_name" {
|
|
t.Fail()
|
|
}
|
|
|
|
if fieldDBName(&structs.Field{Name: "fIELD_nAMe"}) != "field_name" {
|
|
t.Fail()
|
|
}
|
|
}
|
|
|
|
func TestDBModelAttrib(t *testing.T) {
|
|
str := fieldDescript(&structs.Field{
|
|
Name: "Field_naME1",
|
|
Type: "int",
|
|
Description: "Hello world",
|
|
})
|
|
if str != "`gorm:\"column:field_name1;type:INT;comment:Hello world\"`" {
|
|
t.Fail()
|
|
}
|
|
}
|
|
|
|
func TestVarNameUpper(t *testing.T) {
|
|
if str := fieldNamePrepare("tile_server"); str != "TileServer" {
|
|
t.Error("Field name not equal")
|
|
return
|
|
}
|
|
}
|
|
|
|
func TestVarNameLower(t *testing.T) {
|
|
if str := fieldNameLowerPrepare("TileServer"); str != "tile_server" {
|
|
t.Error("Field name not equal")
|
|
return
|
|
}
|
|
}
|