From 40902070c5dbb0cf38fbd5e401ec1392f883d510 Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Wed, 4 May 2016 09:29:36 +0800 Subject: [PATCH 1/4] Add all test in Makefile. Signed-off-by: Bo-Yi Wu --- .gitignore | 1 + Makefile | 21 ++++++++++++--------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 91a8b23..0302cf1 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,4 @@ gorush/log/*.log build.tar.gz gorush.tar.gz gorush.db +vendor diff --git a/Makefile b/Makefile index d94e559..98917ce 100644 --- a/Makefile +++ b/Makefile @@ -11,20 +11,23 @@ all: build build: clean sh script/build.sh -test: memory_test redis_test boltdb_test - cd gorush && go test -cover -v -coverprofile=coverage.out - -memory_test: - cd storage/memory && go test -v -cover *.go +test: redis_test boltdb_test memory_test config_test + go test -cover -v -coverprofile=coverage.out ./gorush/... redis_test: - cd storage/redis && go test -v -cover *.go + go test -v -cover -coverprofile=coverage.out ./storage/redis/... boltdb_test: - cd storage/boltdb && go test -v -cover *.go + go test -v -cover -coverprofile=coverage.out ./storage/boltdb/... -html: test - cd gorush && go tool cover -html=coverage.out +memory_test: + go test -v -cover -coverprofile=coverage.out ./storage/memory/... + +config_test: + go test -v -cover -coverprofile=coverage.out ./config/... + +html: + go tool cover -html=coverage.out docker_build: clean tar -zcvf build.tar.gz gorush.go gorush From 3c03839e2e715c091fc49a0203d4129b0456ff5e Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Wed, 4 May 2016 09:40:48 +0800 Subject: [PATCH 2/4] update coverage. Signed-off-by: Bo-Yi Wu --- config/config_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/config/config_test.go b/config/config_test.go index ae694d8..158f0a7 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -43,3 +43,11 @@ func TestReadConfig(t *testing.T) { assert.Equal(t, "8088", config.Core.Port) assert.True(t, config.Android.Enabled) } + +// Test config file. +func TestDefaultConfig(t *testing.T) { + config := BuildDefaultPushConf() + + assert.Equal(t, "8088", config.Core.Port) + assert.False(t, config.Android.Enabled) +} From 372825245cd2d33d9c7f61b71e36309eee7e1a23 Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Wed, 4 May 2016 10:53:17 +0800 Subject: [PATCH 3/4] Fix #80 support glide package management Signed-off-by: Bo-Yi Wu --- .travis.yml | 9 +++++++-- Makefile | 10 +++++----- glide.lock | 27 +++++++++++++++++++++++++++ glide.yaml | 16 ++++++++++++++++ 4 files changed, 55 insertions(+), 7 deletions(-) create mode 100644 glide.lock create mode 100644 glide.yaml diff --git a/.travis.yml b/.travis.yml index 3ea246e..3ddf9d3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,13 +19,18 @@ env: - secure: MVVH7ilA3r3eLb1I9/KTn3hWaEWOhY8yeF1g2zO09r0oRwEr+NKba/Ey2TpBmkcbFt+CiKMrefzoG9dwHyHm9dFH/1OLBrRAXK3RLV6qyMNw708yOkc7NfH5xK7X7F2u0vWwagK3aVkhTxXGrIQvaEK5jJ2tK3K1uDO5TzUC4TM0hLsgGvyTah89LJBhM4k0OEcAIVmzPO58Ql+RZV3nw03LDtcLofVFNqApCAUJNPrArt9TP/UraPPg/R8WtAS/PMY6IsMRKWj3LjN/J089zfQgiHH6p2wPBQ0n2R2zgisnxjAz5wt6/Dkvo09UqkVWFGX4p6N4t7kxAZoqhRRt+t38qdDip5iloclHGO5eI3/dr30V88Y5ionLL81WsBRqFuMmWrEb86maSMsXWl5yM1qB76Rsh/sPMDRk99Wf9RqhHedJxek6reoUcTBZl9kgXJDlqpjEogyq6qgL0jCCqgl0N6FZAYE/5SvW82MCukZZmko2UXBS/GmU6fhBRGquzOczL43YvVqqV8olZ2qXIdeeX5KeO/SHMUvW3oUnENa6V49K6ZX1f7KG8p8jERTNuDfsdgvZdMSYR2EeDQ7RTU6fhoc3BX4cFyTrS1qImswoBvLCEr54awQXDhgWddZsIWQzCxw6TmD7u25G3YHTsM5Wvs2Gj4z0aJeXFlLSfSQ= - secure: jbMSWnlmLHAXtI1A22aDyUvVWbXq1aRjW1EXcMyzAamBMl4c+47lrkoCnHuQaCY4kOWJ4ux7zPrnXL2j0HTqF7ZXzbw0TixG9dm8MK4TEImCcTcR8VQYbCCdiCM+MKy3XTewN2e1lCAzYu4oKO6xt424yvlowuWiunWZ9YVFfKRpXvfWDd9Rt20PYP7cPyqifRdk4aKI8H+hXWGdeRkRoQvZMa1TdFwRmyg0jfrw94xz/GKNLsSXIu3XBY4LSzzBNUmfcIPpK2TuqAyLxb4d/L+OXG5KQZpydLJgE+GGxtqyAcNkK1ps4Qf3ua6DbGVdQ6Zg0db3g5OLu5LsyvO2jQQIPUQbVDRwwHmT2pDRhz8e8VUMGmokgMX2gAXjxJJ3CFPZAaR9VAzhtlQxbrFi5zSU7VAv92XLNNAdQhA+FFQryC/myI0V82reVWUlXMZsKqBdn5Zq7EA2AsW06NxW8REewUb3o9gauz+B8jAAXtIXZEXWVGqVLXLQceokAWQgrhOBKuE8H3Fuq1tT5VqaDcbvPT0LEU4FdSVBd1+JU0W9nJ4SF2nivJ4tCeZRgtKhaoG2n5gwM9L3fSdZTSrcZL4Gn9XfDZL5hV5GezrdGGGMfhtfIllJPFv3TjYNUlo3F2L3QB9D6SQR3VeLXHAB+IHw6VWwkOSqfEQVf4d8kHo= +before_install: + - sudo add-apt-repository ppa:masterminds/glide -y && sudo apt-get update + - sudo apt-get install -y glide + install: - - go get -t -v ./... + - export GO15VENDOREXPERIMENT=1 + - glide install - go get golang.org/x/tools/cmd/cover - go get github.com/mattn/goveralls script: - - cd gorush && go test -v -covermode=count -coverprofile=coverage.out + - make test - $(go env GOPATH | awk 'BEGIN{FS=":"} {print $1}')/bin/goveralls -coverprofile=coverage.out -service=travis-ci -repotoken=$COVERALLS_TOKEN diff --git a/Makefile b/Makefile index 98917ce..1e88b03 100644 --- a/Makefile +++ b/Makefile @@ -12,19 +12,19 @@ build: clean sh script/build.sh test: redis_test boltdb_test memory_test config_test - go test -cover -v -coverprofile=coverage.out ./gorush/... + go test -v -cover -covermode=count -coverprofile=coverage.out ./gorush/... redis_test: - go test -v -cover -coverprofile=coverage.out ./storage/redis/... + go test -v -cover -covermode=count -coverprofile=coverage.out ./storage/redis/... boltdb_test: - go test -v -cover -coverprofile=coverage.out ./storage/boltdb/... + go test -v -cover -covermode=count -coverprofile=coverage.out ./storage/boltdb/... memory_test: - go test -v -cover -coverprofile=coverage.out ./storage/memory/... + go test -v -cover -covermode=count -coverprofile=coverage.out ./storage/memory/... config_test: - go test -v -cover -coverprofile=coverage.out ./config/... + go test -v -cover -covermode=count -coverprofile=coverage.out ./config/... html: go tool cover -html=coverage.out diff --git a/glide.lock b/glide.lock new file mode 100644 index 0000000..22ab1b9 --- /dev/null +++ b/glide.lock @@ -0,0 +1,27 @@ +hash: 9b3d3cc7501fe305ef404c9441144d834679a6cfc5e60e0006cb7fd36e525584 +updated: 2016-05-03T12:00:10.412823603+08:00 +imports: +- name: github.com/appleboy/gin-status-api + version: 6e9d17f8a41d142221548f0493486dfffc492652 +- name: github.com/appleboy/gofight + version: d902822d4cc09742e326960c813fb7f7ed324fcc +- name: github.com/buger/jsonparser + version: f0ac9350516a2f00f02704daa15e5d1ed5b0b76b +- name: github.com/fvbock/endless + version: dd6ed5d07b55d55cf8342731bbbb96bd20283b7d +- name: github.com/gin-gonic/gin + version: 542be2fe77724f800fcab7eb6c01a4e597fb8506 +- name: github.com/google/go-gcm + version: 1708036c4639349562068ad2d4df2364cd0a1004 +- name: github.com/sideshow/apns2 + version: 729daff3d4e45239f3b584580aa408572737c5b1 + subpackages: + - certificate + - payload +- name: github.com/Sirupsen/logrus + version: cd7d1bbe41066b6c1f19780f895901052150a575 +- name: github.com/stretchr/testify + version: c5d7a69bf8a2c9c374798160849c071093e41dd1 + subpackages: + - assert +devImports: [] diff --git a/glide.yaml b/glide.yaml new file mode 100644 index 0000000..dad6460 --- /dev/null +++ b/glide.yaml @@ -0,0 +1,16 @@ +package: github.com/appleboy/gorush +import: +- package: github.com/gin-gonic/gin +- package: github.com/stretchr/testify + subpackages: + - assert +- package: github.com/appleboy/gofight +- package: github.com/buger/jsonparser +- package: github.com/appleboy/gin-status-api +- package: github.com/fvbock/endless +- package: github.com/google/go-gcm +- package: github.com/sideshow/apns2 + subpackages: + - certificate + - payload +- package: github.com/Sirupsen/logrus From b9ca0395a22c3f47f05b773d2be04584469a2888 Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Wed, 4 May 2016 11:05:44 +0800 Subject: [PATCH 4/4] update packages dependency. Signed-off-by: Bo-Yi Wu --- .travis.yml | 2 +- Makefile | 6 ++ glide.lock | 156 ++++++++++++++++++++++++++++++++++++++++++++++++++-- glide.yaml | 16 +++--- 4 files changed, 168 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3ddf9d3..10133a8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,7 +21,7 @@ env: before_install: - sudo add-apt-repository ppa:masterminds/glide -y && sudo apt-get update - - sudo apt-get install -y glide + - sudo apt-get install -y --force-yes glide install: - export GO15VENDOREXPERIMENT=1 diff --git a/Makefile b/Makefile index 1e88b03..3a8cf08 100644 --- a/Makefile +++ b/Makefile @@ -49,6 +49,12 @@ endif docker tag -f $(PRODUCTION_IMAGE):latest $(DEPLOY_ACCOUNT)/$(PRODUCTION_IMAGE):$(tag) docker push $(DEPLOY_ACCOUNT)/$(PRODUCTION_IMAGE):$(tag) +bundle: + glide install + +bundle_update: + glide update --all-dependencies --resolve-current + lint: golint gorush diff --git a/glide.lock b/glide.lock index 22ab1b9..bc695c1 100644 --- a/glide.lock +++ b/glide.lock @@ -1,27 +1,175 @@ -hash: 9b3d3cc7501fe305ef404c9441144d834679a6cfc5e60e0006cb7fd36e525584 -updated: 2016-05-03T12:00:10.412823603+08:00 +hash: 4e05c4dd1a8106a87fee3b589dd32aecc7ffeb1246bed8f8516b32fe745034d6 +updated: 2016-05-04T14:26:47.161898051+08:00 imports: +- name: github.com/alecthomas/kingpin + version: e1543c77ba157565dbf7b3e8e4e15087a120397f +- name: github.com/alecthomas/template + version: a0175ee3bccc567396460bf5acd36800cb10c49c + subpackages: + - parse +- name: github.com/alecthomas/units + version: 2efee857e7cfd4f3d0138cc3cbb1b4966962b93a +- name: github.com/aliafshar/toylog + version: 11d228569d74fd7a2c9d50016043ccc31e6832ed - name: github.com/appleboy/gin-status-api version: 6e9d17f8a41d142221548f0493486dfffc492652 - name: github.com/appleboy/gofight version: d902822d4cc09742e326960c813fb7f7ed324fcc +- name: github.com/asdine/storm + version: 877bb85183441419d77e7f91ce65a6ccc92a4ff6 + subpackages: + - codec + - codec/gob +- name: github.com/boltdb/bolt + version: d97499360d1ecebc492ea66c7447ea948f417620 - name: github.com/buger/jsonparser version: f0ac9350516a2f00f02704daa15e5d1ed5b0b76b +- name: github.com/davecgh/go-spew + version: 5215b55f46b2b919f50a1df0eaa5886afe4e3b3d + subpackages: + - spew +- name: github.com/dchest/siphash + version: 6d8617816bb5d8268011ffbfb8720f17ce9af63c +- name: github.com/dgrijalva/jwt-go + version: a2c85815a77d0f951e33ba4db5ae93629a1530af +- name: github.com/dgryski/go-ddmin + version: f7df7ebd4081e6d5d5efc4c70e9c871c9af4ccc0 +- name: github.com/dustin/go-broadcast + version: 3bdf6d4a7164a50bc19d5f230e2981d87d2584f1 +- name: github.com/fatih/structs + version: 73c4e3dc02a78deaba8640d5f3a8c236ec1352bf +- name: github.com/fukata/golang-stats-api-handler + version: ab9f90f16caab828afda479fd34bfbbbba2efcee - name: github.com/fvbock/endless version: dd6ed5d07b55d55cf8342731bbbb96bd20283b7d - name: github.com/gin-gonic/gin version: 542be2fe77724f800fcab7eb6c01a4e597fb8506 + subpackages: + - binding + - render +- name: github.com/golang/protobuf + version: 2402d76f3d41f928c7902a765dfc872356dd3aad + subpackages: + - proto + - proto/testdata +- name: github.com/golang/snappy + version: 43fea289edce21979658cbbdb3925390890aa86e - name: github.com/google/go-gcm version: 1708036c4639349562068ad2d4df2364cd0a1004 +- name: github.com/gorilla/context + version: a8d44e7d8e4d532b6a27a02dd82abb31cc1b01bd +- name: github.com/gorilla/mux + version: 9c19ed558d5df4da88e2ade9c8940d742aef0e7e +- name: github.com/jpillora/backoff + version: 0496a6c14df020789376f4d4a261273d5ddb36ec +- name: github.com/julienschmidt/httprouter + version: 77366a47451a56bb3ba682481eed85b64fea14e8 +- name: github.com/klauspost/compress + version: 14eb9c4951195779ecfbec34431a976de7335b0a + subpackages: + - flate + - gzip + - zlib +- name: github.com/klauspost/cpuid + version: 09cded8978dc9e80714c4d85b0322337b0a1e5e0 +- name: github.com/klauspost/crc32 + version: 19b0b332c9e4516a6370a0456e6182c3b5036720 +- name: github.com/labstack/echo + version: 682a5580b7a1009eeea5cdc57db005b85ea7a560 + subpackages: + - engine + - test +- name: github.com/labstack/gommon + version: 2e62be24dbb1ceb226554aaccfe5a89ec71043b3 + subpackages: + - log + - bytes + - color +- name: github.com/mailru/easyjson + version: 7b35f91cec5814b29803a7d9fd5517f638761e67 + subpackages: + - jlexer + - jwriter + - buffer +- name: github.com/manucorporat/sse + version: ee05b128a739a0fb76c7ebd3ae4810c1de808d6d +- name: github.com/manucorporat/stats + version: 8f2d6ace262eba462e9beb552382c98be51d807b +- name: github.com/mattn/go-colorable + version: 45ce6a6f60010487dd0dbab368b5fbbed1c14ef0 +- name: github.com/mattn/go-isatty + version: 56b76bdf51f7708750eac80fa38b952bb9f32639 +- name: github.com/mattn/go-xmpp + version: 12d5633a9d4d91f910e7f6a26b8654c23d5a890f +- name: github.com/pborman/uuid + version: c55201b036063326c5b1b89ccfe45a184973d073 +- name: github.com/pmezard/go-difflib + version: 792786c7400a136282c1664665ae0a8db921c6c2 + subpackages: + - difflib +- name: github.com/pquerna/ffjson + version: 0ffb2b0305b5927b936a35dc3a440fdfede62420 + subpackages: + - fflib/v1 + - fflib/v1/internal +- name: github.com/Sereal/Sereal + version: c6226708d1fbcead06ef8a3b23af0c91925fb612 + subpackages: + - Go/sereal - name: github.com/sideshow/apns2 version: 729daff3d4e45239f3b584580aa408572737c5b1 subpackages: - certificate - payload - name: github.com/Sirupsen/logrus - version: cd7d1bbe41066b6c1f19780f895901052150a575 + version: 4b6ea7319e214d98c938f12692336f7ca9348d6b +- name: github.com/stretchr/objx + version: cbeaeb16a013161a98496fad62933b1d21786672 - name: github.com/stretchr/testify - version: c5d7a69bf8a2c9c374798160849c071093e41dd1 + version: f390dcf405f7b83c997eac1b06768bb9f44dec18 subpackages: - assert + - http + - mock +- name: github.com/ugorji/go + version: a396ed22fc049df733440d90efe17475e3929ccb + subpackages: + - codec +- name: github.com/valyala/fasthttp + version: 3509bd8a7d1d9e9a9a4e8594e78af85fc01e2fba + subpackages: + - expvarhandler +- name: github.com/valyala/fasttemplate + version: 3b874956e03f1636d171bda64b130f9135f42cff +- name: golang.org/x/crypto + version: 2cb52d93744fdc9a51f5c87b36fe2208d424af5a + subpackages: + - pkcs12 + - ssh/terminal + - pkcs12/internal/rc2 +- name: golang.org/x/net + version: f315505cf3349909cdf013ea56690da34e96a451 + subpackages: + - context + - http2 + - http2/hpack +- name: gopkg.in/airbrake/gobrake.v2 + version: 31c8ff1fb8b79a6947e6565e9a6df535f98a6b94 +- name: gopkg.in/alecthomas/kingpin.v2 + version: 8cccfa8eb2e3183254457fb1749b2667fbc364c7 +- name: gopkg.in/bsm/ratelimit.v1 + version: db14e161995a5177acef654cb0dd785e8ee8bc22 +- name: gopkg.in/gemnasium/logrus-airbrake-hook.v2 + version: 31e6fd4bd5a98d8ee7673d24bc54ec73c31810dd +- name: gopkg.in/go-playground/validator.v8 + version: c193cecd124b5cc722d7ee5538e945bdb3348435 +- name: gopkg.in/redis.v3 + version: 5183f8dcde9737db7583dbfa9881800dba26e3fa + subpackages: + - internal + - internal/consistenthash + - internal/hashtag + - internal/pool +- name: gopkg.in/yaml.v2 + version: a83829b6f1293c91addabc89d0571c246397bbf4 devImports: [] diff --git a/glide.yaml b/glide.yaml index dad6460..f5dcef0 100644 --- a/glide.yaml +++ b/glide.yaml @@ -1,16 +1,18 @@ package: github.com/appleboy/gorush import: -- package: github.com/gin-gonic/gin -- package: github.com/stretchr/testify - subpackages: - - assert -- package: github.com/appleboy/gofight -- package: github.com/buger/jsonparser +- package: gopkg.in/yaml.v2 +- package: gopkg.in/redis.v3 +- package: github.com/Sirupsen/logrus + version: v0.10.0 - package: github.com/appleboy/gin-status-api - package: github.com/fvbock/endless +- package: github.com/gin-gonic/gin - package: github.com/google/go-gcm - package: github.com/sideshow/apns2 subpackages: - certificate - payload -- package: github.com/Sirupsen/logrus +- package: github.com/stretchr/testify +- package: github.com/asdine/storm +- package: github.com/appleboy/gofight +- package: github.com/buger/jsonparser