-
Notifications
You must be signed in to change notification settings - Fork 26
/
gen_test.go
54 lines (46 loc) · 958 Bytes
/
gen_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package yee
import (
"fmt"
"log"
"os"
"strings"
"testing"
)
var test = `
type GenCodeVal struct {
${ATTRIBUTE}
}
`
func jk(t string) {
test = strings.Replace(test, "${ATTRIBUTE}", t, -1)
f, err := os.OpenFile("koala.go", os.O_WRONLY&os.O_CREATE, 0666)
if err != nil {
log.Println(err.Error())
}
_, err = f.Write([]byte(test))
if err != nil {
log.Println(err.Error())
}
f.Close()
}
func TestNew(t *testing.T) {
c := []map[string]string{{"a": "int"}, {"k": "string"}}
//l := ""
for _, i := range c {
fmt.Println(i)
//fmt.Println(c[j])
}
}
var exprCase = []expr{{Name: "Username", Expr: "username =?", TP: "string"}, {Name: "Age", Expr: "age > ?", TP: "int"}}
func TestGenQueryExpr(t *testing.T) {
GenQueryExpr(exprCase)
}
func TestGenerateRestfulAPI(t *testing.T) {
k := GenCodeVal{
Package: "manage",
QueryExpr: exprCase,
Page: "20",
Modal: "modal.core_account",
}
fmt.Println(GenerateRestfulAPI(k))
}