mirror of
https://github.com/go-admin-team/go-admin.git
synced 2026-09-22 10:33:13 +00:00
45 lines
814 B
Go
45 lines
814 B
Go
package test
|
|
|
|
import (
|
|
"go-admin/models/tools"
|
|
"os"
|
|
"testing"
|
|
"text/template"
|
|
)
|
|
|
|
func TestGoModelTemplate(t *testing.T) {
|
|
t1, err := template.ParseFiles("model.go.template")
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
table := tools.SysTables{}
|
|
table.TableName = "sys_tables"
|
|
tab, _ := table.Get()
|
|
file, err := os.Create("models/"+table.PackageName+".go")
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
defer file.Close()
|
|
|
|
_ = t1.Execute(file, tab)
|
|
t.Log("")
|
|
}
|
|
|
|
func TestGoApiTemplate(t *testing.T) {
|
|
t1, err := template.ParseFiles("api.go.template")
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
table := tools.SysTables{}
|
|
table.TableName = "sys_tables"
|
|
tab, _ := table.Get()
|
|
file, err := os.Create("apis/"+table.PackageName+".go")
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
defer file.Close()
|
|
|
|
_ = t1.Execute(file, tab)
|
|
t.Log("")
|
|
}
|