Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Phodal
Coca
提交
572b89ed
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 搜索 >>
未验证
提交
572b89ed
编写于
1月 09, 2020
作者:
P
Phodal Huang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: rename api for expose
上级
147dd59b
变更
18
隐藏空白更改
内联
并排
Showing
18 changed file
with
62 addition
and
40 deletion
+62
-40
cmd/api_test.go
cmd/api_test.go
+5
-4
cmd/arch_test.go
cmd/arch_test.go
+3
-2
cmd/bs_test.go
cmd/bs_test.go
+2
-1
cmd/call_test.go
cmd/call_test.go
+3
-2
cmd/cloc_test.go
cmd/cloc_test.go
+3
-2
cmd/coca_test.go
cmd/coca_test.go
+6
-10
cmd/concept_test.go
cmd/concept_test.go
+3
-2
cmd/count_test.go
cmd/count_test.go
+3
-2
cmd/dep_test.go
cmd/dep_test.go
+3
-2
cmd/evaluate_test.go
cmd/evaluate_test.go
+3
-2
cmd/git_test.go
cmd/git_test.go
+2
-1
cmd/rcall_test.go
cmd/rcall_test.go
+3
-2
cmd/refactor_test.go
cmd/refactor_test.go
+3
-2
cmd/suggest_test.go
cmd/suggest_test.go
+3
-2
cmd/tbs_test.go
cmd/tbs_test.go
+2
-1
cmd/todo_test.go
cmd/todo_test.go
+3
-2
cmd/version_test.go
cmd/version_test.go
+2
-1
cocatest/testcase/testcase.go
cocatest/testcase/testcase.go
+10
-0
未找到文件。
cmd/api_test.go
浏览文件 @
572b89ed
package
cmd
import
(
"github.com/phodal/coca/cocatest/testcase"
"testing"
)
func
TestApi
(
t
*
testing
.
T
)
{
path
:=
"../_fixtures/call"
analysis
:=
[]
CmdTestCase
{{
analysis
:=
[]
testcase
.
CmdTestCase
{{
Name
:
"analysis"
,
Cmd
:
"analysis -p "
+
path
,
Golden
:
""
,
}}
RunTestCmd
(
t
,
analysis
)
tests
:=
[]
CmdTestCase
{{
tests
:=
[]
testcase
.
CmdTestCase
{{
Name
:
"api"
,
Cmd
:
"api -c -f -p "
+
path
,
Golden
:
"testdata/api.txt"
,
...
...
@@ -25,14 +26,14 @@ func TestApi(t *testing.T) {
func
Test_ApiWithSortRemove
(
t
*
testing
.
T
)
{
path
:=
"../_fixtures/call"
analysis
:=
[]
CmdTestCase
{{
analysis
:=
[]
testcase
.
CmdTestCase
{{
Name
:
"analysis"
,
Cmd
:
"analysis -p "
+
path
,
Golden
:
""
,
}}
RunTestCmd
(
t
,
analysis
)
tests
:=
[]
CmdTestCase
{{
tests
:=
[]
testcase
.
CmdTestCase
{{
Name
:
"api"
,
Cmd
:
"api -c -s -r com.phodal.pholedge.book. -p"
+
path
,
Golden
:
"testdata/api_sort_remove.txt"
,
...
...
cmd/arch_test.go
浏览文件 @
572b89ed
package
cmd
import
(
"github.com/phodal/coca/cocatest/testcase"
"testing"
)
func
TestArch
(
t
*
testing
.
T
)
{
abs
:=
"../_fixtures/arch"
analysis
:=
[]
CmdTestCase
{{
analysis
:=
[]
testcase
.
CmdTestCase
{{
Name
:
"analysis"
,
Cmd
:
"analysis -p "
+
abs
,
Golden
:
""
,
}}
RunTestCmd
(
t
,
analysis
)
tests
:=
[]
CmdTestCase
{{
tests
:=
[]
testcase
.
CmdTestCase
{{
Name
:
"arch"
,
Cmd
:
"arch -P "
,
Golden
:
""
,
...
...
cmd/bs_test.go
浏览文件 @
572b89ed
package
cmd
import
(
"github.com/phodal/coca/cocatest/testcase"
"testing"
)
func
TestBadSmell
(
t
*
testing
.
T
)
{
abs
:=
"../_fixtures/bs"
tests
:=
[]
CmdTestCase
{{
tests
:=
[]
testcase
.
CmdTestCase
{{
Name
:
"bs"
,
Cmd
:
"bs -s type -p "
+
abs
,
Golden
:
""
,
...
...
cmd/call_test.go
浏览文件 @
572b89ed
package
cmd
import
(
"github.com/phodal/coca/cocatest/testcase"
"testing"
)
func
TestCall
(
t
*
testing
.
T
)
{
abs
:=
"../_fixtures/arch"
analysis
:=
[]
CmdTestCase
{{
analysis
:=
[]
testcase
.
CmdTestCase
{{
Name
:
"analysis"
,
Cmd
:
"analysis -p "
+
abs
,
Golden
:
""
,
}}
RunTestCmd
(
t
,
analysis
)
tests
:=
[]
CmdTestCase
{{
tests
:=
[]
testcase
.
CmdTestCase
{{
Name
:
"call"
,
Cmd
:
"call -r com"
,
Golden
:
""
,
...
...
cmd/cloc_test.go
浏览文件 @
572b89ed
package
cmd
import
(
"github.com/phodal/coca/cocatest/testcase"
"testing"
)
func
TestCloc
(
t
*
testing
.
T
)
{
analysis
:=
[]
CmdTestCase
{{
analysis
:=
[]
testcase
.
CmdTestCase
{{
Name
:
"analysis"
,
Cmd
:
"analysis -p ."
,
Golden
:
""
,
}}
RunTestCmd
(
t
,
analysis
)
tests
:=
[]
CmdTestCase
{{
tests
:=
[]
testcase
.
CmdTestCase
{{
Name
:
"cloc"
,
Cmd
:
"cloc"
,
Golden
:
""
,
...
...
cmd/coca_test.go
浏览文件 @
572b89ed
...
...
@@ -3,6 +3,7 @@ package cmd
import
(
"bytes"
"github.com/mattn/go-shellwords"
"github.com/phodal/coca/cocatest/testcase"
"github.com/spf13/cobra"
"os"
"path/filepath"
...
...
@@ -10,19 +11,15 @@ import (
"testing"
)
// CmdTestCase describes a test case that works with releases.
type
CmdTestCase
struct
{
Name
string
Cmd
string
Golden
string
WantError
bool
func
RunTestCmd
(
t
*
testing
.
T
,
tests
[]
testcase
.
CmdTestCase
)
{
RunTestCaseWithCmd
(
t
,
tests
)
}
func
RunTestC
md
(
t
*
testing
.
T
,
tests
[]
CmdTestCase
)
{
func
RunTestC
aseWithCmd
(
t
*
testing
.
T
,
tests
[]
testcase
.
CmdTestCase
)
{
t
.
Helper
()
for
_
,
tt
:=
range
tests
{
t
.
Run
(
tt
.
Name
,
func
(
t
*
testing
.
T
)
{
defer
r
esetEnv
()()
defer
R
esetEnv
()()
t
.
Log
(
"running Cmd: "
,
tt
.
Cmd
)
_
,
output
,
err
:=
executeActionCommandC
(
tt
.
Cmd
)
...
...
@@ -47,7 +44,6 @@ func executeActionCommandC(cmd string) (*cobra.Command, string, error) {
buf
:=
new
(
bytes
.
Buffer
)
command
:=
NewRootCmd
(
buf
)
command
.
SetOut
(
buf
)
command
.
SetArgs
(
args
)
c
,
err
:=
command
.
ExecuteC
()
...
...
@@ -55,7 +51,7 @@ func executeActionCommandC(cmd string) (*cobra.Command, string, error) {
return
c
,
buf
.
String
(),
err
}
func
r
esetEnv
()
func
()
{
func
R
esetEnv
()
func
()
{
origEnv
:=
os
.
Environ
()
return
func
()
{
os
.
Clearenv
()
...
...
cmd/concept_test.go
浏览文件 @
572b89ed
package
cmd
import
(
"github.com/phodal/coca/cocatest/testcase"
"testing"
)
func
TestConcept
(
t
*
testing
.
T
)
{
analysis
:=
[]
CmdTestCase
{{
analysis
:=
[]
testcase
.
CmdTestCase
{{
Name
:
"analysis"
,
Cmd
:
"analysis -p ../_fixtures/examples/api"
,
Golden
:
""
,
}}
RunTestCmd
(
t
,
analysis
)
tests
:=
[]
CmdTestCase
{{
tests
:=
[]
testcase
.
CmdTestCase
{{
Name
:
"concept"
,
Cmd
:
"concept"
,
Golden
:
""
,
...
...
cmd/count_test.go
浏览文件 @
572b89ed
package
cmd
import
(
"github.com/phodal/coca/cocatest/testcase"
"testing"
)
func
TestCount
(
t
*
testing
.
T
)
{
abs
:=
"../_fixtures/examples/rename"
analysis
:=
[]
CmdTestCase
{{
analysis
:=
[]
testcase
.
CmdTestCase
{{
Name
:
"analysis"
,
Cmd
:
"analysis -p "
+
abs
,
Golden
:
""
,
}}
RunTestCmd
(
t
,
analysis
)
tests
:=
[]
CmdTestCase
{{
tests
:=
[]
testcase
.
CmdTestCase
{{
Name
:
"count"
,
Cmd
:
"count -t 1"
,
Golden
:
"testdata/count.txt"
,
...
...
cmd/dep_test.go
浏览文件 @
572b89ed
package
cmd
import
(
"github.com/phodal/coca/cocatest/testcase"
"testing"
)
func
Test_Dep_MavenFindUnused
(
t
*
testing
.
T
)
{
tests
:=
[]
CmdTestCase
{{
tests
:=
[]
testcase
.
CmdTestCase
{{
Name
:
"dep"
,
Cmd
:
"deps -p ../_fixtures/deps/maven_sample"
,
Golden
:
"testdata/deps_maven.txt"
,
...
...
@@ -14,7 +15,7 @@ func Test_Dep_MavenFindUnused(t *testing.T) {
}
func
Test_Dep_GradleFindUnused
(
t
*
testing
.
T
)
{
tests
:=
[]
CmdTestCase
{{
tests
:=
[]
testcase
.
CmdTestCase
{{
Name
:
"dep"
,
Cmd
:
"deps -p ../_fixtures/deps/gradle_sample"
,
Golden
:
"testdata/deps_gradle.txt"
,
...
...
cmd/evaluate_test.go
浏览文件 @
572b89ed
package
cmd
import
(
"github.com/phodal/coca/cocatest/testcase"
"testing"
)
func
TestEvaluate
(
t
*
testing
.
T
)
{
analysis
:=
[]
CmdTestCase
{{
analysis
:=
[]
testcase
.
CmdTestCase
{{
Name
:
"analysis"
,
Cmd
:
"analysis -p ../_fixtures/arch"
,
Golden
:
""
,
}}
RunTestCmd
(
t
,
analysis
)
tests
:=
[]
CmdTestCase
{{
tests
:=
[]
testcase
.
CmdTestCase
{{
Name
:
"evaluate"
,
Cmd
:
"evaluate"
,
Golden
:
"testdata/evaluate.txt"
,
...
...
cmd/git_test.go
浏览文件 @
572b89ed
package
cmd
import
(
"github.com/phodal/coca/cocatest/testcase"
"testing"
)
// Todo: fake it
func
TestGit
(
t
*
testing
.
T
)
{
tests
:=
[]
CmdTestCase
{{
tests
:=
[]
testcase
.
CmdTestCase
{{
Name
:
"git"
,
Cmd
:
"git -a -f -t -b -o -r com -s 10 -m"
,
Golden
:
""
,
...
...
cmd/rcall_test.go
浏览文件 @
572b89ed
package
cmd
import
(
"github.com/phodal/coca/cocatest/testcase"
"testing"
)
func
TestRCall
(
t
*
testing
.
T
)
{
analysis
:=
[]
CmdTestCase
{{
analysis
:=
[]
testcase
.
CmdTestCase
{{
Name
:
"analysis"
,
Cmd
:
"analysis -p ../_fixtures/call"
,
Golden
:
""
,
}}
RunTestCmd
(
t
,
analysis
)
tests
:=
[]
CmdTestCase
{{
tests
:=
[]
testcase
.
CmdTestCase
{{
Name
:
"rcall"
,
Cmd
:
"rcall -r com -c com"
,
Golden
:
"testdata/rcall_normal.txt"
,
...
...
cmd/refactor_test.go
浏览文件 @
572b89ed
package
cmd
import
(
"github.com/phodal/coca/cocatest/testcase"
"testing"
)
func
TestRefactorMove
(
t
*
testing
.
T
)
{
tests
:=
[]
CmdTestCase
{{
tests
:=
[]
testcase
.
CmdTestCase
{{
Name
:
"refactor"
,
Cmd
:
"refactor -p . -m ."
,
Golden
:
""
,
...
...
@@ -14,7 +15,7 @@ func TestRefactorMove(t *testing.T) {
}
func
TestRefactorRename
(
t
*
testing
.
T
)
{
tests
:=
[]
CmdTestCase
{{
tests
:=
[]
testcase
.
CmdTestCase
{{
Name
:
"refactor"
,
Cmd
:
"refactor -p . -R . -m ."
,
Golden
:
""
,
...
...
cmd/suggest_test.go
浏览文件 @
572b89ed
package
cmd
import
(
"github.com/phodal/coca/cocatest/testcase"
"testing"
)
func
TestSuggest
(
t
*
testing
.
T
)
{
analysis
:=
[]
CmdTestCase
{{
analysis
:=
[]
testcase
.
CmdTestCase
{{
Name
:
"analysis"
,
Cmd
:
"analysis -p ../_fixtures/suggest"
,
Golden
:
""
,
}}
RunTestCmd
(
t
,
analysis
)
tests
:=
[]
CmdTestCase
{{
tests
:=
[]
testcase
.
CmdTestCase
{{
Name
:
"suggest"
,
Cmd
:
"suggest"
,
Golden
:
"testdata/suggest_normal.txt"
,
...
...
cmd/tbs_test.go
浏览文件 @
572b89ed
package
cmd
import
(
"github.com/phodal/coca/cocatest/testcase"
"testing"
)
func
TestTbs
(
t
*
testing
.
T
)
{
tests
:=
[]
CmdTestCase
{{
tests
:=
[]
testcase
.
CmdTestCase
{{
Name
:
"tbs"
,
Cmd
:
"tbs -p ../_fixtures/tbs/code -s "
,
Golden
:
"testdata/tbs_normal.txt"
,
...
...
cmd/todo_test.go
浏览文件 @
572b89ed
package
cmd
import
(
"github.com/phodal/coca/cocatest/testcase"
"testing"
)
func
Test_ShouldOutputCount
(
t
*
testing
.
T
)
{
tests
:=
[]
CmdTestCase
{{
tests
:=
[]
testcase
.
CmdTestCase
{{
Name
:
"todo"
,
Cmd
:
"todo -p ../_fixtures/todo"
,
Golden
:
"testdata/todo_normal.txt"
,
...
...
@@ -15,7 +16,7 @@ func Test_ShouldOutputCount(t *testing.T) {
//TODO: update func for CI which clone depth = 1
func
TestTodo
(
t
*
testing
.
T
)
{
tests
:=
[]
CmdTestCase
{{
tests
:=
[]
testcase
.
CmdTestCase
{{
Name
:
"todo"
,
Cmd
:
"todo -p ../_fixtures/todo -g"
,
Golden
:
""
,
...
...
cmd/version_test.go
浏览文件 @
572b89ed
package
cmd
import
(
"github.com/phodal/coca/cocatest/testcase"
"testing"
)
func
TestVersion
(
t
*
testing
.
T
)
{
tests
:=
[]
CmdTestCase
{{
tests
:=
[]
testcase
.
CmdTestCase
{{
Name
:
"version"
,
Cmd
:
"version"
,
Golden
:
""
,
...
...
cocatest/testcase/testcase.go
0 → 100644
浏览文件 @
572b89ed
package
testcase
// CmdTestCase describes a test case that works with releases.
type
CmdTestCase
struct
{
Name
string
Cmd
string
Golden
string
WantError
bool
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录