1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-14 22:40:55 +00:00

testing: fix temporary create failed on Windows

We are creating temporary files on the root directory of beego now
This PR using system temporary directory for testing.

Fixes #4243
This commit is contained in:
Allen.M 2020-09-30 15:50:40 +08:00
parent f6519b29a8
commit 6ffbc0a2b8
2 changed files with 9 additions and 5 deletions

View File

@ -125,8 +125,8 @@ func TestGetUint64(t *testing.T) {
}
func TestAdditionalViewPaths(t *testing.T) {
dir1 := "_beeTmp"
dir2 := "_beeTmp2"
dir1 := tmpDir("TestAdditionalViewPaths1")
dir2 := tmpDir("TestAdditionalViewPaths2")
defer os.RemoveAll(dir1)
defer os.RemoveAll(dir2)

View File

@ -45,8 +45,12 @@ var block = `{{define "block"}}
<h1>Hello, blocks!</h1>
{{end}}`
func tmpDir(s string) string {
return filepath.Join(os.TempDir(), s)
}
func TestTemplate(t *testing.T) {
dir := "_beeTmp"
dir := tmpDir("TestTemplate")
files := []string{
"header.tpl",
"index.tpl",
@ -107,7 +111,7 @@ var user = `<!DOCTYPE html>
`
func TestRelativeTemplate(t *testing.T) {
dir := "_beeTmp"
dir := tmpDir("TestRelativeTemplate")
//Just add dir to known viewPaths
if err := AddViewPath(dir); err != nil {
@ -218,7 +222,7 @@ var output = `<!DOCTYPE html>
`
func TestTemplateLayout(t *testing.T) {
dir := "_beeTmp"
dir := tmpDir("TestTemplateLayout")
files := []string{
"add.tpl",
"layout_blog.tpl",