github.com/kunlun-qilian/sqlx/v3@v3.0.0/generator/sql_func_generator_test.go (about)

     1  package generator
     2  
     3  import (
     4  	"os"
     5  	"path/filepath"
     6  	"testing"
     7  
     8  	"github.com/go-courier/packagesx"
     9  )
    10  
    11  func TestSqlFuncGenerator(t *testing.T) {
    12  	cwd, _ := os.Getwd()
    13  	pkg, _ := packagesx.Load(filepath.Join(cwd, "./__examples__/database"))
    14  
    15  	for _, name := range []string{"User", "Org"} {
    16  		g := NewSqlFuncGenerator(pkg)
    17  		g.WithComments = true
    18  		g.WithTableName = true
    19  		g.WithTableInterfaces = true
    20  		g.WithMethods = true
    21  		g.Database = "DBTest"
    22  		g.StructName = name
    23  
    24  		g.Scan()
    25  		g.Output(cwd)
    26  	}
    27  }