Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Phodal
Coca
提交
dc2ab88c
C
Coca
项目概览
Phodal
/
Coca
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
Coca
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
dc2ab88c
编写于
1月 06, 2020
作者:
P
Phodal Huang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: [cmd-test] add test for cmd
上级
ec8ec0f3
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
33 addition
and
10 deletion
+33
-10
cmd/api.go
cmd/api.go
+1
-2
cmd/api_test.go
cmd/api_test.go
+1
-1
cmd/coca_test.go
cmd/coca_test.go
+3
-1
cmd/count.go
cmd/count.go
+1
-2
cmd/count_test.go
cmd/count_test.go
+1
-1
cmd/evaluate.go
cmd/evaluate.go
+1
-2
cmd/evaluate_test.go
cmd/evaluate_test.go
+1
-1
cmd/testdata/api.txt
cmd/testdata/api.txt
+8
-0
cmd/testdata/count.txt
cmd/testdata/count.txt
+5
-0
cmd/testdata/evaluate.txt
cmd/testdata/evaluate.txt
+11
-0
未找到文件。
cmd/api.go
浏览文件 @
dc2ab88c
...
...
@@ -10,7 +10,6 @@ import (
"github.com/phodal/coca/core/domain"
"github.com/spf13/cobra"
"log"
"os"
"regexp"
"strconv"
"strings"
...
...
@@ -73,7 +72,7 @@ var apiCmd = &cobra.Command{
}
if
apiCmdConfig
.
ShowCount
{
table
:=
tablewriter
.
NewWriter
(
o
s
.
Stdo
ut
)
table
:=
tablewriter
.
NewWriter
(
o
utp
ut
)
table
.
SetHeader
([]
string
{
"Size"
,
"Method"
,
"Uri"
,
"Caller"
})
...
...
cmd/api_test.go
浏览文件 @
dc2ab88c
...
...
@@ -19,7 +19,7 @@ func TestApi(t *testing.T) {
tests
:=
[]
cmdTestCase
{{
name
:
"api"
,
cmd
:
"api -c -f -p "
+
abs
,
golden
:
""
,
golden
:
"
testdata/api.txt
"
,
}}
runTestCmd
(
t
,
tests
)
}
\ No newline at end of file
cmd/coca_test.go
浏览文件 @
dc2ab88c
...
...
@@ -5,6 +5,7 @@ import (
"github.com/mattn/go-shellwords"
"github.com/spf13/cobra"
"os"
"path/filepath"
"strings"
"testing"
)
...
...
@@ -29,7 +30,8 @@ func runTestCmd(t *testing.T, tests []cmdTestCase) {
t
.
Errorf
(
"expected error, got '%v'"
,
err
)
}
if
tt
.
golden
!=
""
{
AssertGoldenString
(
t
,
output
,
tt
.
golden
)
slash
:=
filepath
.
FromSlash
(
tt
.
golden
)
AssertGoldenString
(
t
,
output
,
slash
)
}
})
}
...
...
cmd/count.go
浏览文件 @
dc2ab88c
...
...
@@ -10,7 +10,6 @@ import (
"github.com/phodal/coca/core/infrastructure/string_helper"
"github.com/spf13/cobra"
"log"
"os"
"strconv"
)
...
...
@@ -50,7 +49,7 @@ var countCmd = &cobra.Command{
callMapSort
=
callMapSort
[
:
countCmdConfig
.
Top
]
}
table
:=
tablewriter
.
NewWriter
(
o
s
.
Stdo
ut
)
table
:=
tablewriter
.
NewWriter
(
o
utp
ut
)
table
.
SetHeader
([]
string
{
"Refs Count"
,
"method"
})
for
_
,
count
:=
range
callMapSort
{
...
...
cmd/count_test.go
浏览文件 @
dc2ab88c
...
...
@@ -19,7 +19,7 @@ func TestCount(t *testing.T) {
tests
:=
[]
cmdTestCase
{{
name
:
"count"
,
cmd
:
"count -t 1"
,
golden
:
"testdata/count.txt"
,
golden
:
filepath
.
FromSlash
(
"testdata/count.txt"
)
,
}}
runTestCmd
(
t
,
tests
)
}
cmd/evaluate.go
浏览文件 @
dc2ab88c
...
...
@@ -10,7 +10,6 @@ import (
"github.com/phodal/coca/core/domain"
"github.com/spf13/cobra"
"log"
"os"
"strconv"
)
...
...
@@ -46,7 +45,7 @@ var evaluateCmd = &cobra.Command{
cModel
,
_
:=
json
.
MarshalIndent
(
result
,
""
,
"
\t
"
)
cmd_util
.
WriteToCocaFile
(
"evaluate.json"
,
string
(
cModel
))
table
:=
tablewriter
.
NewWriter
(
o
s
.
Stdo
ut
)
table
:=
tablewriter
.
NewWriter
(
o
utp
ut
)
table
.
SetHeader
([]
string
{
"Type"
,
"Count"
,
"Level"
,
"Total"
,
"Rate"
})
classCount
:=
result
.
Summary
.
ClassCount
...
...
cmd/evaluate_test.go
浏览文件 @
dc2ab88c
...
...
@@ -19,7 +19,7 @@ func TestEvaluate(t *testing.T) {
tests
:=
[]
cmdTestCase
{{
name
:
"evaluate"
,
cmd
:
"evaluate"
,
golden
:
""
,
golden
:
"
testdata/evaluate.txt
"
,
}}
runTestCmd
(
t
,
tests
)
}
\ No newline at end of file
cmd/testdata/api.txt
0 → 100644
浏览文件 @
dc2ab88c
+------+--------+-------------+-----------------------------------------------------+
| SIZE | METHOD | URI | CALLER |
+------+--------+-------------+-----------------------------------------------------+
| 2 | POST | /books | com.phodal.pholedge.book.BookController.createBook |
| 2 | PUT | /books/{id} | com.phodal.pholedge.book.BookController.updateBook |
| 2 | GET | /books/ | com.phodal.pholedge.book.BookController.getBookList |
| 2 | GET | /books/{id} | com.phodal.pholedge.book.BookController.getBookById |
+------+--------+-------------+-----------------------------------------------------+
cmd/testdata/count.txt
浏览文件 @
dc2ab88c
+------------+--------------------------------------+
| REFS COUNT | METHOD |
+------------+--------------------------------------+
| 1 | repositories.AggregateRootARepo.save |
+------------+--------------------------------------+
cmd/testdata/evaluate.txt
0 → 100644
浏览文件 @
dc2ab88c
+--------------------------------+-------+-----------------------+-------+----------+
| TYPE | COUNT | LEVEL | TOTAL | RATE |
+--------------------------------+-------+-----------------------+-------+----------+
| Nullable / Return Null | 0 | Method | 6 | 0.00% |
| Utils | 0 | Class | 14 | 0.00% |
| Static Method | 1 | Method | 6 | 0.00% |
| Average Method Num. | 6 | Method/Class | 14 | 0.428571 |
| Method Num. Std Dev / 标准差 | 6 | Class | - | 0.646206 |
| Average Method Length | 0 | Without Getter/Setter | 0 | NaN |
| Method Length Std Dev / 标准差 | 6 | Method | - | NaN |
+--------------------------------+-------+-----------------------+-------+----------+
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录