fix: fix path issue for windows

上级 0170d1eb
......@@ -10,6 +10,7 @@ import (
"github.com/phodal/coca/core/domain"
"github.com/spf13/cobra"
"log"
"path/filepath"
"regexp"
"strconv"
"strings"
......@@ -93,7 +94,7 @@ var apiCmd = &cobra.Command{
func forceUpdateApi() {
app := new(api.JavaApiApp)
restApis = app.AnalysisPath(apiCmdConfig.Path, parsedDeps, identifiersMap, diMap)
restApis = app.AnalysisPath(filepath.FromSlash(apiCmdConfig.Path), parsedDeps, identifiersMap, diMap)
cModel, _ := json.MarshalIndent(restApis, "", "\t")
cmd_util.WriteToCocaFile("apis.json", string(cModel))
}
......
package cmd
import (
"path/filepath"
"testing"
)
func TestApi(t *testing.T) {
abs, _ := filepath.Abs("../_fixtures/call")
abs = filepath.FromSlash(abs)
path := "../_fixtures/call"
analysis := []cmdTestCase{{
name: "analysis",
cmd: "analysis -p " + abs,
cmd: "analysis -p " + path,
golden: "",
}}
runTestCmd(t, analysis)
tests := []cmdTestCase{{
name: "api",
cmd: "api -c -f -p " + abs,
cmd: "api -c -f -p " + path,
golden: "testdata/api.txt",
}}
runTestCmd(t, tests)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册