refactor file|path (#1409)

Co-authored-by: anqiansong <anqiansong@bytedance.com>
This commit is contained in:
anqiansong
2022-01-03 21:32:40 +08:00
committed by GitHub
parent 290de6aa96
commit 89ce5e492b
81 changed files with 279 additions and 245 deletions

View File

@@ -9,7 +9,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/tal-tech/go-zero/tools/goctl/api/parser/g4/ast"
"github.com/tal-tech/go-zero/tools/goctl/util"
"github.com/tal-tech/go-zero/tools/goctl/util/pathx"
)
var (
@@ -119,7 +119,7 @@ func TestApiParser(t *testing.T) {
})
t.Run("nestedImport", func(t *testing.T) {
file := filepath.Join(util.MustTempDir(), "foo.api")
file := filepath.Join(pathx.MustTempDir(), "foo.api")
err := ioutil.WriteFile(file, []byte(nestedAPIImport), os.ModePerm)
if err != nil {
return
@@ -149,7 +149,7 @@ func TestApiParser(t *testing.T) {
})
t.Run("ambiguousSyntax", func(t *testing.T) {
file := filepath.Join(util.MustTempDir(), "foo.api")
file := filepath.Join(pathx.MustTempDir(), "foo.api")
err := ioutil.WriteFile(file, []byte(ambiguousSyntax), os.ModePerm)
if err != nil {
return
@@ -163,7 +163,7 @@ func TestApiParser(t *testing.T) {
})
t.Run("ambiguousSyntax", func(t *testing.T) {
file := filepath.Join(util.MustTempDir(), "foo.api")
file := filepath.Join(pathx.MustTempDir(), "foo.api")
err := ioutil.WriteFile(file, []byte(ambiguousSyntax), os.ModePerm)
if err != nil {
return
@@ -177,7 +177,7 @@ func TestApiParser(t *testing.T) {
})
t.Run("ambiguousService", func(t *testing.T) {
file := filepath.Join(util.MustTempDir(), "foo.api")
file := filepath.Join(pathx.MustTempDir(), "foo.api")
err := ioutil.WriteFile(file, []byte(ambiguousService), os.ModePerm)
if err != nil {
return
@@ -207,7 +207,7 @@ func TestApiParser(t *testing.T) {
`)
assert.Error(t, err)
file := filepath.Join(util.MustTempDir(), "foo.api")
file := filepath.Join(pathx.MustTempDir(), "foo.api")
err = ioutil.WriteFile(file, []byte(duplicateHandler), os.ModePerm)
if err != nil {
return
@@ -236,7 +236,7 @@ func TestApiParser(t *testing.T) {
`)
assert.Error(t, err)
file := filepath.Join(util.MustTempDir(), "foo.api")
file := filepath.Join(pathx.MustTempDir(), "foo.api")
err = ioutil.WriteFile(file, []byte(duplicateRoute), os.ModePerm)
if err != nil {
return
@@ -260,7 +260,7 @@ func TestApiParser(t *testing.T) {
`)
assert.Error(t, err)
file := filepath.Join(util.MustTempDir(), "foo.api")
file := filepath.Join(pathx.MustTempDir(), "foo.api")
err = ioutil.WriteFile(file, []byte(duplicateType), os.ModePerm)
if err != nil {
return