From 8f25fcc275c29ece2c4833293f88513cb5a70386 Mon Sep 17 00:00:00 2001 From: hantmac Date: Sun, 18 Aug 2019 12:09:54 +0800 Subject: [PATCH 1/2] Add Some Unit Test --- backend/config/config_test.go | 16 ++++++++++++++++ backend/database/mongo_test.go | 19 +++++++++++++++++++ backend/go.mod | 1 + 3 files changed, 36 insertions(+) create mode 100644 backend/config/config_test.go create mode 100644 backend/database/mongo_test.go diff --git a/backend/config/config_test.go b/backend/config/config_test.go new file mode 100644 index 00000000..ee966877 --- /dev/null +++ b/backend/config/config_test.go @@ -0,0 +1,16 @@ +package config + +import ( + . "github.com/smartystreets/goconvey/convey" + "testing" +) + +func TestInitConfig(t *testing.T) { + Convey("Test InitConfig func", t, func() { + x := InitConfig("") + + Convey("The value should be nil", func() { + So(x, ShouldEqual, nil) + }) + }) +} diff --git a/backend/database/mongo_test.go b/backend/database/mongo_test.go new file mode 100644 index 00000000..a73ae6df --- /dev/null +++ b/backend/database/mongo_test.go @@ -0,0 +1,19 @@ +package database + +import ( + . "github.com/smartystreets/goconvey/convey" + "github.com/spf13/viper" + "testing" +) + +func TestGetDb(t *testing.T) { + Convey("Test GetDb", t, func() { + s, db := GetDb() + Convey("The value should be Session.Copy", func() { + So(s, ShouldEqual, Session.Copy()) + }) + Convey("The value should be reference of database", func() { + So(db, ShouldEqual, s.DB(viper.GetString("mongo.db"))) + }) + }) +} diff --git a/backend/go.mod b/backend/go.mod index 2128b3f7..5a575910 100644 --- a/backend/go.mod +++ b/backend/go.mod @@ -11,5 +11,6 @@ require ( github.com/gomodule/redigo v2.0.0+incompatible github.com/pkg/errors v0.8.1 github.com/satori/go.uuid v1.2.0 + github.com/smartystreets/goconvey v0.0.0-20190731233626-505e41936337 github.com/spf13/viper v1.4.0 ) From 1aae0d5575224ed7ef89b6eb73121391bd57d9ad Mon Sep 17 00:00:00 2001 From: Marvin Zhang Date: Sun, 18 Aug 2019 12:57:44 +0800 Subject: [PATCH 2/2] updated README --- README-zh.md | 17 +++++++++++++++-- README.md | 15 +++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/README-zh.md b/README-zh.md index 7194f987..fa9d45be 100644 --- a/README-zh.md +++ b/README-zh.md @@ -4,6 +4,7 @@ ![](https://img.shields.io/github/release/tikazyq/crawlab.svg) ![](https://img.shields.io/github/last-commit/tikazyq/crawlab.svg) ![](https://img.shields.io/github/issues/tikazyq/crawlab.svg) +![](https://img.shields.io/github/contributers/tikazyq/crawlab.svg) ![](https://img.shields.io/docker/pulls/tikazyq/crawlab) ![](https://img.shields.io/github/license/tikazyq/crawlab.svg) @@ -242,8 +243,6 @@ Crawlab使用起来很方便,也很通用,可以适用于几乎任何主流 注意,Crawlab将取文件名作为爬虫名称,这个您可以后期更改。另外,请不要将zip文件名设置为中文,可能会导致上传不成功。 -#### - ## 相关文章 - [爬虫管理平台Crawlab v0.3.0发布(Golang版本)](https://juejin.im/post/5d418deff265da03c926d75c) @@ -256,6 +255,20 @@ Crawlab使用起来很方便,也很通用,可以适用于几乎任何主流 **注意: v0.3.0版本已将基于Celery的Python版本切换为了Golang版本,如何部署请参照文档** +## 贡献者 + + + + + + + + + + + + + ## 社区 & 赞助 如果您觉得Crawlab对您的日常开发或公司有帮助,请加作者微信 tikazyq1 并注明"Crawlab",作者会将你拉入群。或者,您可以扫下方支付宝二维码给作者打赏去升级团队协作软件或买一杯咖啡。 diff --git a/README.md b/README.md index 94221862..689a224d 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ ![](https://img.shields.io/github/release/tikazyq/crawlab.svg) ![](https://img.shields.io/github/last-commit/tikazyq/crawlab.svg) ![](https://img.shields.io/github/issues/tikazyq/crawlab.svg) +![](https://img.shields.io/github/contributers/tikazyq/crawlab.svg) ![](https://img.shields.io/docker/pulls/tikazyq/crawlab) ![](https://img.shields.io/github/license/tikazyq/crawlab.svg) @@ -219,6 +220,20 @@ Crawlab is easy to use, general enough to adapt spiders in any language and any | [Gerapy](https://github.com/Gerapy/Gerapy) | Admin Platform | Y | Y | Y | [Scrapyd](https://github.com/scrapy/scrapyd) | Web Service | Y | N | N/A +## Contributors + + + + + + + + + + + + + ## Community & Sponsorship If you feel Crawlab could benefit your daily work or your company, please add the author's Wechat account noting "Crawlab" to enter the discussion group. Or you scan the Alipay QR code below to give us a reward to upgrade our teamwork software or buy a coffee.