background/test/utils_test.go

24 lines
533 B
Go

package test
import (
"background/utils"
"log"
"testing"
)
func TestDDL2ORM(t *testing.T) {
ddl := `
CREATE TABLE project (
id int(13) NOT NULL AUTO_INCREMENT,
title varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
content longblob,
contact_info varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
`
tbname, fields := utils.DDL2Field(ddl)
log.Print(tbname, fields)
gocode := utils.CreateGoStruct(tbname,fields)
log.Print(gocode)
}