Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Phodal
Coca
提交
6d15456f
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 搜索 >>
未验证
提交
6d15456f
编写于
12月 21, 2019
作者:
P
Phodal Huang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
tests: move to go
上级
df3a2eb6
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
82 addition
and
80 deletion
+82
-80
.travis.yml
.travis.yml
+4
-5
core/domain/gitt/gitt.coverprofile
core/domain/gitt/gitt.coverprofile
+1
-0
core/domain/gitt/gitt.go
core/domain/gitt/gitt.go
+1
-0
core/domain/gitt/gitt_test.go
core/domain/gitt/gitt_test.go
+53
-45
scripts/go.test.sh
scripts/go.test.sh
+12
-0
test/call_api_test.go
test/call_api_test.go
+11
-17
test/coca_suite_test.go
test/coca_suite_test.go
+0
-13
未找到文件。
.travis.yml
浏览文件 @
6d15456f
...
...
@@ -21,9 +21,11 @@ git:
install
:
true
before_install
:
-
go get -t -v ./...
script
:
-
go test -v ./...
-
ginkgo -r --randomizeAllSpecs --randomizeSuites --failOnPending --coverpkg gitserver --trace --race --compilers=2
-
./scripts/go.test.sh
#
#os:
...
...
@@ -32,7 +34,4 @@ script:
# - windows
after_success
:
-
gover . coverage.txt
-
ls -al
-
cat coverage.txt
-
bash <(curl -s https://codecov.io/bash)
core/domain/gitt/gitt.coverprofile
0 → 100644
浏览文件 @
6d15456f
mode: atomic
core/domain/gitt/gitt.go
浏览文件 @
6d15456f
...
...
@@ -46,6 +46,7 @@ func BuildCommitMessage() []CommitMessage {
}
func
BuildMessageByInput
(
inputStr
string
)
[]
CommitMessage
{
currentFileChanges
=
nil
commitMessages
=
nil
splitStr
:=
strings
.
Split
(
inputStr
,
"
\n
"
)
for
_
,
str
:=
range
splitStr
{
...
...
tes
t/gitt_test.go
→
core/domain/git
t/gitt_test.go
浏览文件 @
6d15456f
package
test_tes
t
package
git
t
import
(
"coca/core/domain/gitt"
.
"github.com/onsi/ginkgo"
.
"github.com/onsi/gomega"
"testing"
)
var
_
=
Describe
(
"Git Parser"
,
func
()
{
Context
(
"Test for Range"
,
func
()
{
It
(
"support for long commits"
,
func
()
{
result
:=
gitt
.
BuildMessageByInput
(
`
func
Test_should_success_parse_log
(
t
*
testing
.
T
)
{
//t.Parallel()
g
:=
NewGomegaWithT
(
t
)
result
:=
BuildMessageByInput
(
`
[828fe39523] Rossen Stoyanchev 2019-12-04 Consistently use releaseBody in DefaultWebClient
5 3 spring-webflux/core/main/java/org/springframework/web/reactive/function/client/ClientResponse.java
1 1 spring-webflux/core/main/java/org/springframework/web/reactive/function/client/DefaultWebClient.java
...
...
@@ -17,18 +17,19 @@ var _ = Describe("Git Parser", func() {
6 11 core/docs/asciidoc/web/webflux-webclient.adoc
`
)
Expect
(
result
[
0
]
.
Rev
)
.
To
(
Equal
(
"828fe39523"
))
Expect
(
result
[
0
]
.
Date
)
.
To
(
Equal
(
"2019-12-04"
))
Expect
(
result
[
0
]
.
Author
)
.
To
(
Equal
(
"Rossen Stoyanchev"
))
Expect
(
result
[
0
]
.
Message
)
.
To
(
Equal
(
"Consistently use releaseBody in DefaultWebClient"
))
Expect
(
len
(
result
[
0
]
.
Changes
))
.
To
(
Equal
(
4
))
Expect
(
result
[
0
]
.
Changes
[
0
]
.
File
)
.
To
(
Equal
(
"spring-webflux/core/main/java/org/springframework/web/reactive/function/client/ClientResponse.java"
))
})
})
Context
(
"Test for Move file"
,
func
()
{
It
(
"should have a current file move update"
,
func
()
{
messages
:=
gitt
.
BuildMessageByInput
(
`
g
.
Expect
(
result
[
0
]
.
Rev
)
.
To
(
Equal
(
"828fe39523"
))
g
.
Expect
(
result
[
0
]
.
Date
)
.
To
(
Equal
(
"2019-12-04"
))
g
.
Expect
(
result
[
0
]
.
Author
)
.
To
(
Equal
(
"Rossen Stoyanchev"
))
g
.
Expect
(
result
[
0
]
.
Message
)
.
To
(
Equal
(
"Consistently use releaseBody in DefaultWebClient"
))
g
.
Expect
(
len
(
result
[
0
]
.
Changes
))
.
To
(
Equal
(
4
))
g
.
Expect
(
result
[
0
]
.
Changes
[
0
]
.
File
)
.
To
(
Equal
(
"spring-webflux/core/main/java/org/springframework/web/reactive/function/client/ClientResponse.java"
))
}
func
Test_identify_file_move
(
t
*
testing
.
T
)
{
//t.Parallel()
g
:=
NewGomegaWithT
(
t
)
messages
:=
BuildMessageByInput
(
`
[d00f0124d] Phodal Huang 2019-12-19 update files
0 0 core/domain/bs/BadSmellApp.go
...
...
@@ -44,14 +45,17 @@ var _ = Describe("Git Parser", func() {
1 1 cmd/bs.go
0 0 core/adapter/bs/BadSmellApp.go
`
)
summary
:=
gitt
.
GetTeamSummary
(
messages
)
Expect
(
summary
[
0
]
.
EntityName
)
.
To
(
Equal
(
"core/adapter/bs/BadSmellApp.go"
))
Expect
(
summary
[
1
]
.
EntityName
)
.
To
(
Equal
(
"cmd/bs.go"
))
Expect
(
len
(
summary
))
.
To
(
Equal
(
2
))
})
It
(
"support for first path change"
,
func
()
{
messages
:=
gitt
.
BuildMessageByInput
(
`
summary
:=
GetTeamSummary
(
messages
)
g
.
Expect
(
summary
[
0
]
.
EntityName
)
.
To
(
Equal
(
"core/adapter/bs/BadSmellApp.go"
))
g
.
Expect
(
summary
[
1
]
.
EntityName
)
.
To
(
Equal
(
"cmd/bs.go"
))
g
.
Expect
(
len
(
summary
))
.
To
(
Equal
(
2
))
}
func
Test_identify_first_file_move
(
t
*
testing
.
T
)
{
//t.Parallel()
g
:=
NewGomegaWithT
(
t
)
messages
:=
BuildMessageByInput
(
`
[333] Phodal Huang 2019-12-19 update files
0 0 src/domain/gitt/README.md
...
...
@@ -59,13 +63,16 @@ var _ = Describe("Git Parser", func() {
0 0 {src => core}/domain/gitt/README.md
`
)
summary
:=
gitt
.
GetTeamSummary
(
messages
)
Expect
(
summary
[
0
]
.
EntityName
)
.
To
(
Equal
(
"core/domain/gitt/README.md"
))
Expect
(
len
(
summary
))
.
To
(
Equal
(
1
))
})
summary
:=
GetTeamSummary
(
messages
)
g
.
Expect
(
summary
[
0
]
.
EntityName
)
.
To
(
Equal
(
"core/domain/gitt/README.md"
))
g
.
Expect
(
len
(
summary
))
.
To
(
Equal
(
1
))
}
It
(
"should update child"
,
func
()
{
result
:=
gitt
.
BuildMessageByInput
(
`
func
Test_identify_move_to_directory
(
t
*
testing
.
T
)
{
t
.
Parallel
()
g
:=
NewGomegaWithT
(
t
)
result
:=
BuildMessageByInput
(
`
[ef9165d] Phodal Huang 2019-12-18 fefactor: extract vars
0 0 adapter/JavaCallListener.go
...
...
@@ -73,13 +80,16 @@ var _ = Describe("Git Parser", func() {
0 0 adapter/{ => call}/JavaCallListener.go
`
)
summary
:=
gitt
.
GetTeamSummary
(
result
)
Expect
(
summary
[
0
]
.
EntityName
)
.
To
(
Equal
(
"adapter/call/JavaCallListener.go"
))
Expect
(
len
(
summary
))
.
To
(
Equal
(
1
))
})
summary
:=
GetTeamSummary
(
result
)
g
.
Expect
(
summary
[
0
]
.
EntityName
)
.
To
(
Equal
(
"adapter/call/JavaCallListener.go"
))
g
.
Expect
(
len
(
summary
))
.
To
(
Equal
(
1
))
}
func
Test_identify_direct_move
(
t
*
testing
.
T
)
{
//t.Parallel()
g
:=
NewGomegaWithT
(
t
)
It
(
"should enable handle start move"
,
func
()
{
result
:=
gitt
.
BuildMessageByInput
(
`
result
:=
BuildMessageByInput
(
`
[ef9165d] Phodal Huang 2019-12-18 fefactor: extract vars
0 0 language/java/JavaParser.tokens
...
...
@@ -87,9 +97,7 @@ var _ = Describe("Git Parser", func() {
0 0 language/java/JavaParser.tokens => src/language/java/JavaLexer.tokens
`
)
summary
:=
gitt
.
GetTeamSummary
(
result
)
Expect
(
len
(
summary
))
.
To
(
Equal
(
1
))
Expect
(
summary
[
0
]
.
EntityName
)
.
To
(
Equal
(
"src/language/java/JavaLexer.tokens"
))
})
})
})
\ No newline at end of file
summary
:=
GetTeamSummary
(
result
)
g
.
Expect
(
len
(
summary
))
.
To
(
Equal
(
1
))
g
.
Expect
(
summary
[
0
]
.
EntityName
)
.
To
(
Equal
(
"src/language/java/JavaLexer.tokens"
))
}
\ No newline at end of file
scripts/go.test.sh
0 → 100755
浏览文件 @
6d15456f
#!/usr/bin/env bash
set
-e
echo
""
>
coverage.txt
for
d
in
$(
go list ./... |
grep
-v
vendor
)
;
do
go
test
-race
-coverprofile
=
profile.out
-covermode
=
atomic
"
$d
"
if
[
-f
profile.out
]
;
then
cat
profile.out
>>
coverage.txt
rm
profile.out
fi
done
\ No newline at end of file
test/call_api_test.go
浏览文件 @
6d15456f
...
...
@@ -5,27 +5,22 @@ import (
"coca/core/models"
"coca/core/support"
"encoding/json"
.
"github.com/onsi/ginkgo"
.
"github.com/onsi/gomega"
"
lo
g"
"
testin
g"
)
var
_
=
Describe
(
"Git Parser"
,
func
()
{
Context
(
"Test for Range"
,
func
()
{
It
(
"should be a novel"
,
func
()
{
var
parsedDeps
[]
models
.
JClassNode
analyser
:=
call_graph
.
NewCallGraph
()
file
:=
support
.
ReadFile
(
"_fixtures/call_api_test.json"
)
if
file
==
nil
{
log
.
Fatal
(
"lost file:"
)
}
func
Test_should_generate_correct_files
(
t
*
testing
.
T
)
{
g
:=
NewGomegaWithT
(
t
)
_
=
json
.
Unmarshal
(
file
,
&
parsedDeps
)
var
parsedDeps
[]
models
.
JClassNode
analyser
:=
call_graph
.
NewCallGraph
()
file
:=
support
.
ReadFile
(
"_fixtures/call_api_test.json"
)
_
=
json
.
Unmarshal
(
file
,
&
parsedDeps
)
dotContent
:=
analyser
.
Analysis
(
"com.phodal.pholedge.book.BookController.createBook"
,
*&
parsedDeps
)
dotContent
:=
analyser
.
Analysis
(
"com.phodal.pholedge.book.BookController.createBook"
,
*&
parsedDeps
)
Expect
(
dotContent
)
.
To
(
Equal
(
`digraph G {
g
.
Expect
(
dotContent
)
.
To
(
Equal
(
`digraph G {
"com.phodal.pholedge.book.BookService.createBook" -> "com.phodal.pholedge.book.BookFactory.create";
"com.phodal.pholedge.book.BookService.createBook" -> "com.phodal.pholedge.book.model.command.CreateBookCommand.getIsbn";
"com.phodal.pholedge.book.BookService.createBook" -> "com.phodal.pholedge.book.model.command.CreateBookCommand.getName";
...
...
@@ -34,6 +29,5 @@ var _ = Describe("Git Parser", func() {
"com.phodal.pholedge.book.BookController.createBook" -> "com.phodal.pholedge.book.BookService.createBook";
}
`
))
})
})
})
\ No newline at end of file
}
test/coca_suite_test.go
已删除
100644 → 0
浏览文件 @
df3a2eb6
package
test_test
import
(
"testing"
.
"github.com/onsi/ginkgo"
.
"github.com/onsi/gomega"
)
func
TestCoca
(
t
*
testing
.
T
)
{
RegisterFailHandler
(
Fail
)
RunSpecs
(
t
,
"Coca Suite"
)
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录