-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
接口文档:https://apifox.com/apidoc/shared-4db8eeb6-dec5-4864-b76b-742ccdc633f2/api-147851887 | ||
|
||
答辩文档:https://l1zelk90cop.feishu.cn/docx/Lhkfd9IaxoBiU8xN3upcFSKnnSv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#Deploy in docker | ||
|
||
##Start docker service | ||
`docker-compose up -d` | ||
|
||
##docker containers situation | ||
`docker ps` | ||
|
||
##stop docker service | ||
`docker down -v` | ||
|
||
##relevant details | ||
部署时需要将config.yml文件的相关参数进行修改 | ||
还要注意docker-compose文件的挂载 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,61 @@ | ||
|
||
#explanation | ||
|
||
##cache | ||
 | ||
|
||
##rabbitmq | ||
 | ||
|
||
##flow chart url | ||
https://l1zelk90cop.feishu.cn/docx/PA1MdGRhQofr5lxxOU8cqfDCnWb | ||
|
||
##go test | ||
对部分接口进行了测试,相关的测试代码在cmd文件夹中 | ||
覆盖率测试: `go test -cover file.go file_test.go` | ||
经测试,有: | ||
|
||
*register* ok command-line-arguments 0.392s coverage: 68.8% of statements | ||
|
||
*login* ok command-line-arguments 0.554s coverage: 69.2% of statements | ||
|
||
*PublishVideo* ok command-line-arguments 1.330s coverage: 76.2% of statements | ||
|
||
*ListVideos* ok command-line-arguments 0.446s coverage: 84.2% of statements | ||
|
||
*RelationAction* ok command-line-arguments 0.474s coverage: 66.7% of statements | ||
|
||
*list_following* ok command-line-arguments 0.411s coverage: 60.0% of statements | ||
|
||
主要是对service层的部分函数进行单元测试,原本打算使用mock(sqlmock和redigomock),但实际操作时,经常出一些 | ||
问题,使用起来有点麻烦,就考虑直接初始化mysql和redis并进行连接来进行操作了。 | ||
思路: | ||
|
||
先对(mysql,redis,minio)进行初始化 | ||
|
||
声明一个*app.RequestContext类型变量,需要token的在请求头中设置 | ||
|
||
然后调用service层内相关的函数进行测试 | ||
|
||
单元测试的心得: | ||
|
||
单元测试使用快速轻便,测试的对象是部分的代码,可以在短时间内测试出代码的实际效果 | ||
和质量,提供快速反馈,方便进行修改 | ||
为了编写单元测试,我需要了解所测试代码的实际效果,还要尽力地重构和组织代码,方便代码 | ||
的维护和测试 | ||
go test在实践后有了了解, | ||
基本的单测命令 | ||
go test | ||
可以直接看到执行结果是通过,还是失败 | ||
|
||
go test -v | ||
可以查看到每一个单测函数的执行情况 | ||
|
||
go test -run=xx | ||
run=[所支持正则的字符串] , go test 会去匹配 run 后面的字符串,支持正则,会去匹配到具体的单测函数,并进行测试 | ||
|
||
go test -short | ||
还有一些其他的命令,可以使用 | ||
|
||
此外,对mock,goconvey,assert等包也有了一些了解 | ||
|