-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix oceanbase #607
base: master
Are you sure you want to change the base?
fix oceanbase #607
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -116,7 +116,7 @@ func buildProject(cfgFile string) { | |
} | ||
if p.Driver == "" { | ||
p.Driver = singleSelect(getWord("choose a driver"), | ||
[]string{"mysql", "postgresql", "sqlite", "mssql"}, "mysql") | ||
[]string{"mysql", "postgresql", "sqlite", "mssql", "oceanbase"}, "mysql") | ||
} | ||
p.DriverModule = p.Driver | ||
if p.Driver == db.DriverPostgresql { | ||
|
@@ -238,6 +238,9 @@ func GetCurrentDirectory() string { | |
} | ||
|
||
func installProjectTmpl(p Project, cfg *config.Config, cfgFile string, info *dbInfo) { | ||
if p.Driver == "oceanbase" { | ||
p.Driver = "OceanBase" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need comment for this replace. And maybe it's better to keep the Driver as |
||
} | ||
|
||
t, err := template.New("project").Funcs(map[string]interface{}{ | ||
"title": strings.Title, | ||
|
@@ -248,7 +251,7 @@ func installProjectTmpl(p Project, cfg *config.Config, cfgFile string, info *dbI | |
c, err := format.Source(buf.Bytes()) | ||
checkError(err) | ||
checkError(ioutil.WriteFile("./main.go", c, 0644)) | ||
|
||
p.Driver = "oceanbase" | ||
checkError(os.Mkdir("pages", os.ModePerm)) | ||
checkError(os.Mkdir("tables", os.ModePerm)) | ||
checkError(os.Mkdir("logs", os.ModePerm)) | ||
|
@@ -291,10 +294,26 @@ func Init(c db.Connection) { | |
} | ||
|
||
if defaultLang == "cn" || p.Language == language.CN || p.Language == "cn" { | ||
checkError(ioutil.WriteFile("./main_test.go", mainTestCN, 0644)) | ||
t, err := template.New("project").Funcs(map[string]interface{}{ | ||
"title": strings.Title, | ||
}).Parse(mainTest["mainTestCN"]) | ||
checkError(err) | ||
buf := new(bytes.Buffer) | ||
checkError(t.Execute(buf, p)) | ||
c, err := format.Source(buf.Bytes()) | ||
checkError(err) | ||
checkError(ioutil.WriteFile("./main_test.go", c, 0644)) | ||
checkError(ioutil.WriteFile("./README.md", []byte(fmt.Sprintf(readmeCN, p.Port+"/"+p.Prefix)), 0644)) | ||
} else { | ||
checkError(ioutil.WriteFile("./main_test.go", mainTest, 0644)) | ||
t, err := template.New("project").Funcs(map[string]interface{}{ | ||
"title": strings.Title, | ||
}).Parse(mainTest["mainTest"]) | ||
checkError(err) | ||
buf := new(bytes.Buffer) | ||
checkError(t.Execute(buf, p)) | ||
c, err := format.Source(buf.Bytes()) | ||
checkError(err) | ||
checkError(ioutil.WriteFile("./main_test.go", c, 0644)) | ||
checkError(ioutil.WriteFile("./README.md", []byte(fmt.Sprintf(readme, p.Port+"/"+p.Prefix)), 0644)) | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1269,58 +1269,58 @@ like Aldus PageMaker including versions of Lorem Ipsum. | |
}, nil | ||
}`) | ||
|
||
var mainTest = []byte(`package main | ||
|
||
import ( | ||
"./tables" | ||
"github.com/GoAdminGroup/go-admin/modules/config" | ||
"github.com/GoAdminGroup/go-admin/tests" | ||
"github.com/GoAdminGroup/go-admin/tests/common" | ||
"github.com/GoAdminGroup/go-admin/tests/frameworks/gin" | ||
"github.com/GoAdminGroup/go-admin/tests/web" | ||
"github.com/gavv/httpexpect" | ||
"log" | ||
"testing" | ||
) | ||
|
||
// Black box testing | ||
func TestMainBlackBox(t *testing.T) { | ||
cfg := config.ReadFromJson("./config.json") | ||
tests.BlackBoxTestSuit(t, gin.NewHandler, cfg.Databases, tables.Generators, func(cfg config.DatabaseList) { | ||
// Data cleaner of the framework | ||
tests.Cleaner(cfg) | ||
// Clean your own data: | ||
// ... | ||
}, func(e *httpexpect.Expect) { | ||
// Test cases of the framework | ||
common.Test(e) | ||
// Write your own API test, for example: | ||
// More usages: https://github.com/gavv/httpexpect | ||
// e.POST("/signin").Expect().Status(http.StatusOK) | ||
}) | ||
} | ||
|
||
// User acceptance testing | ||
func TestMainUserAcceptance(t *testing.T) { | ||
web.UserAcceptanceTestSuit(t, func(t *testing.T, page *web.Page) { | ||
// Write test case base on chromedriver, for example: | ||
// More usages: https://github.com/sclevine/agouti | ||
page.NavigateTo("http://127.0.0.1:9033/admin") | ||
//page.Contain("username") | ||
//page.Click("") | ||
}, func(quit chan struct{}) { | ||
// start the server: | ||
// .... | ||
go startServer() | ||
<-quit | ||
log.Print("test quit") | ||
}, true) // if local parameter is true, it will not be headless, and window not close when finishing tests. | ||
}`) | ||
|
||
var mainTestCN = []byte(`package main | ||
var mainTest = map[string]string{ | ||
"mainTest": `package main | ||
import ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the indentation in the generated code correct? |
||
"{{.Module}}/tables" | ||
"github.com/GoAdminGroup/go-admin/modules/config" | ||
"github.com/GoAdminGroup/go-admin/tests" | ||
"github.com/GoAdminGroup/go-admin/tests/common" | ||
"github.com/GoAdminGroup/go-admin/tests/frameworks/gin" | ||
"github.com/GoAdminGroup/go-admin/tests/web" | ||
"github.com/gavv/httpexpect" | ||
"log" | ||
"testing" | ||
) | ||
// Black box testing | ||
func TestMainBlackBox(t *testing.T) { | ||
cfg := config.ReadFromJson("./config.json") | ||
tests.BlackBoxTestSuit(t, gin.NewHandler, cfg.Databases, tables.Generators, func(cfg config.DatabaseList) { | ||
// Data cleaner of the framework | ||
tests.Cleaner(cfg) | ||
// Clean your own data: | ||
// ... | ||
}, func(e *httpexpect.Expect) { | ||
// Test cases of the framework | ||
common.Test(e) | ||
// Write your own API test, for example: | ||
// More usages: https://github.com/gavv/httpexpect | ||
// e.POST("/signin").Expect().Status(http.StatusOK) | ||
}) | ||
} | ||
// User acceptance testing | ||
func TestMainUserAcceptance(t *testing.T) { | ||
web.UserAcceptanceTestSuit(t, func(t *testing.T, page *web.Page) { | ||
// Write test case base on chromedriver, for example: | ||
// More usages: https://github.com/sclevine/agouti | ||
page.NavigateTo("http://127.0.0.1:9033/admin") | ||
//page.Contain("username") | ||
//page.Click("") | ||
}, func(quit chan struct{}) { | ||
// start the server: | ||
// .... | ||
go startServer() | ||
<-quit | ||
log.Print("test quit") | ||
}, true) // if local parameter is true, it will not be headless, and window not close when finishing tests. | ||
}`, | ||
"mainTestCN": `package main | ||
|
||
import ( | ||
"./tables" | ||
"{{.Module}}/tables" | ||
"github.com/GoAdminGroup/go-admin/modules/config" | ||
"github.com/GoAdminGroup/go-admin/tests" | ||
"github.com/GoAdminGroup/go-admin/tests/common" | ||
|
@@ -1363,7 +1363,8 @@ func TestMainUserAcceptance(t *testing.T) { | |
<-quit | ||
log.Print("test quit") | ||
}, true) | ||
}`) | ||
}`, | ||
} | ||
|
||
var makefile = []byte(`GOCMD = go | ||
GOBUILD = $(GOCMD) build | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should also add oceanbase after
Import and initialize databas
(at line 172).