diff --git a/gaurun/apns_http2.go b/gaurun/apns_http2.go index 8914c33..19bf6cd 100644 --- a/gaurun/apns_http2.go +++ b/gaurun/apns_http2.go @@ -11,9 +11,9 @@ import ( "net/http" "time" - "github.com/RobotsAndPencils/buford/payload" - "github.com/RobotsAndPencils/buford/payload/badge" - "github.com/RobotsAndPencils/buford/push" + "github.com/nohana/buford/payload" + "github.com/nohana/buford/payload/badge" + "github.com/nohana/buford/push" "golang.org/x/net/http2" ) @@ -121,9 +121,11 @@ func NewApnsPayloadHttp2(req *RequestGaurunNotification) map[string]interface{} } func NewApnsHeadersHttp2(req *RequestGaurunNotification) *push.Headers { - var pushType string + var pushType push.PushType if req.PushType == "" { - pushType = ApnsPushTypeAlert + pushType = push.PushTypeAlert + } else { + pushType = push.PushType(req.PushType) } headers := &push.Headers{ Topic: ConfGaurun.Ios.Topic, diff --git a/gaurun/apns_http2_test.go b/gaurun/apns_http2_test.go index d2b4597..a1bb3eb 100644 --- a/gaurun/apns_http2_test.go +++ b/gaurun/apns_http2_test.go @@ -1,24 +1,26 @@ package gaurun import ( - "github.com/stretchr/testify/assert" "testing" + + "github.com/nohana/buford/push" + "github.com/stretchr/testify/assert" ) func TestNewApnsClientHttp2(t *testing.T) { t.Run("when send push type none", func(t *testing.T) { req := &RequestGaurunNotification{} headers := NewApnsHeadersHttp2(req) - assert.Equal(t, ApnsPushTypeAlert, headers.PushType) + assert.Equal(t, push.PushTypeAlert, headers.PushType) }) t.Run("when send push type 'alert'", func(t *testing.T) { - req := &RequestGaurunNotification{PushType: ApnsPushTypeAlert} + req := &RequestGaurunNotification{PushType: string(push.PushTypeAlert)} headers := NewApnsHeadersHttp2(req) - assert.Equal(t, ApnsPushTypeAlert, headers.PushType) + assert.Equal(t, push.PushTypeAlert, headers.PushType) }) t.Run("when send push type 'background'", func(t *testing.T) { - req := &RequestGaurunNotification{PushType: ApnsPushTypeBackground} + req := &RequestGaurunNotification{PushType: string(push.PushTypeBackground)} headers := NewApnsHeadersHttp2(req) - assert.Equal(t, ApnsPushTypeBackground, headers.PushType) + assert.Equal(t, push.PushTypeBackground, headers.PushType) }) } diff --git a/gaurun/const.go b/gaurun/const.go index 7bf9a59..1501ae6 100644 --- a/gaurun/const.go +++ b/gaurun/const.go @@ -15,8 +15,3 @@ const ( StatusFailedPush = "failed-push" StatusDisabledPush = "disabled-push" ) - -const ( - ApnsPushTypeAlert = "alert" - ApnsPushTypeBackground = "background" -) diff --git a/gaurun/worker.go b/gaurun/worker.go index 5ed3913..3220aaf 100644 --- a/gaurun/worker.go +++ b/gaurun/worker.go @@ -6,7 +6,7 @@ import ( "sync" "sync/atomic" - "github.com/RobotsAndPencils/buford/push" + "github.com/nohana/buford/push" ) var ( diff --git a/gaurun/worker_test.go b/gaurun/worker_test.go index f7c35d7..c53b807 100644 --- a/gaurun/worker_test.go +++ b/gaurun/worker_test.go @@ -4,7 +4,7 @@ import ( "errors" "testing" - "github.com/RobotsAndPencils/buford/push" + "github.com/nohana/buford/push" "github.com/stretchr/testify/assert" ) diff --git a/go.mod b/go.mod index cd5bc44..b922a28 100644 --- a/go.mod +++ b/go.mod @@ -1,17 +1,20 @@ module github.com/mercari/gaurun require ( - github.com/BurntSushi/toml v0.2.0 - github.com/RobotsAndPencils/buford v0.12.0 - github.com/client9/reopen v0.0.0-20160619053521-4b86f9c0ead5 + github.com/BurntSushi/toml v0.3.1 + github.com/client9/reopen v1.0.0 github.com/davecgh/go-spew v1.1.1 // indirect github.com/fukata/golang-stats-api-handler v0.0.0-20160325105040-ab9f90f16caa - github.com/lestrrat/go-server-starter v0.0.0-20151125041704-901cec093d58 + github.com/kr/pretty v0.1.0 // indirect + github.com/lestrrat/go-server-starter v0.0.0-20180220115249-6ac0b358431b + github.com/nohana/buford v0.16.0 github.com/pkg/errors v0.8.1 // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/stretchr/testify v0.0.0-20161117074351-18a02ba4a312 - go.uber.org/atomic v1.1.0 // indirect - go.uber.org/zap v0.0.0-20170224221842-12592ca48efc + github.com/stretchr/testify v1.4.0 + go.uber.org/atomic v1.4.0 // indirect + go.uber.org/multierr v1.1.0 // indirect + go.uber.org/zap v1.10.0 golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7 // indirect - golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3 + golang.org/x/net v0.0.0-20190916140828-c8589233b77d + golang.org/x/text v0.3.2 // indirect + gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect ) diff --git a/go.sum b/go.sum index 5a3f0b4..493a0a1 100644 --- a/go.sum +++ b/go.sum @@ -1,31 +1,48 @@ -github.com/BurntSushi/toml v0.2.0 h1:OthAm9ZSUx4uAmn3WbPwc06nowWrByRwBsYRhbmFjBs= -github.com/BurntSushi/toml v0.2.0/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/RobotsAndPencils/buford v0.12.0 h1:2nfOk+N/QVoQHwXIS0m5TFdvlUjEnqAj/0yXKR75azY= -github.com/RobotsAndPencils/buford v0.12.0/go.mod h1:27KhJZ/wLQHRnsZF+mTWKvF5w8U4dVl4Nh+BfQem4Lo= -github.com/client9/reopen v0.0.0-20160619053521-4b86f9c0ead5 h1:46QA9E5dIKm6lNygBd+eSiLF32HsgjJwbA1IELhs5Vo= -github.com/client9/reopen v0.0.0-20160619053521-4b86f9c0ead5/go.mod h1:caXVCEr+lUtoN1FlsRiOWdfQtdRHIYfcb0ai8qKWtkQ= +github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/client9/reopen v1.0.0 h1:8tpLVR74DLpLObrn2KvsyxJY++2iORGR17WLUdSzUws= +github.com/client9/reopen v1.0.0/go.mod h1:caXVCEr+lUtoN1FlsRiOWdfQtdRHIYfcb0ai8qKWtkQ= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/fukata/golang-stats-api-handler v0.0.0-20160325105040-ab9f90f16caa h1:YxLexpeQS0Fz/sNa3QQEgLWyVhgNhEB1GQUi+c45nFs= github.com/fukata/golang-stats-api-handler v0.0.0-20160325105040-ab9f90f16caa/go.mod h1:1sIi4/rHq6s/ednWMZqTmRq3765qTUSs/c3xF6lj8J8= -github.com/lestrrat/go-server-starter v0.0.0-20151125041704-901cec093d58 h1:9/ngkqJb42WLtYR6EFRnImztkmF+n5EhwKBxVOj2B3o= -github.com/lestrrat/go-server-starter v0.0.0-20151125041704-901cec093d58/go.mod h1:3T+o9dIpjId0dpv2Aa7+HivBIW9h9nra0VuN5ARP/ec= +github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/lestrrat/go-server-starter v0.0.0-20180220115249-6ac0b358431b h1:Ial71qYQufttbgLhmAAAgf4Y+p9KRKYklAoE9a8rXOA= +github.com/lestrrat/go-server-starter v0.0.0-20180220115249-6ac0b358431b/go.mod h1:3T+o9dIpjId0dpv2Aa7+HivBIW9h9nra0VuN5ARP/ec= +github.com/nohana/buford v0.16.0 h1:ll9rXR633SosRtSleY7e7iVcJhkj0NNOt63UWFLrUEw= +github.com/nohana/buford v0.16.0/go.mod h1:fe8IsEYZbM4MM3UuXRbBOX2b0T9/Z/Tnkvgjyj0e8s0= github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/testify v0.0.0-20161117074351-18a02ba4a312 h1:UsFdQ3ZmlzS0BqZYGxvYaXvFGUbCmPGy8DM7qWJJiIQ= -github.com/stretchr/testify v0.0.0-20161117074351-18a02ba4a312/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -go.uber.org/atomic v1.1.0 h1:wm63V2eSi29VDCF8+5+V0ruTF+GgWT9cW/J9mpkPtRo= -go.uber.org/atomic v1.1.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= -go.uber.org/zap v0.0.0-20170224221842-12592ca48efc h1:pt7EHxvttVwmn5rrlkwEFkjs4OYEOvbLrQgfrNlHTAY= -go.uber.org/zap v0.0.0-20170224221842-12592ca48efc/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +go.uber.org/atomic v1.4.0 h1:cxzIVoETapQEqDhQu3QfnvXAV4AlzcvUCxkVUFw3+EU= +go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +go.uber.org/multierr v1.1.0 h1:HoEmRHQPVSqub6w2z2d2EOVs2fjyFRGyofhKuyDq0QI= +go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= +go.uber.org/zap v1.10.0 h1:ORx85nbTijNz8ljznvCMR1ZBIPKFn3jQrag10X2AsuM= +go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7 h1:0hQKqeLdqlt5iIwVOBErRisrHJAN57yOiPRQItI20fU= golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3 h1:0GoQqolDA55aaLxZyTzK/Y2ePZzZTUrRacwib7cNsYQ= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190916140828-c8589233b77d h1:mCMDWKhNO37A7GAhOpHPbIw1cjd0V86kX1/WA9c7FZ8= +golang.org/x/net v0.0.0-20190916140828-c8589233b77d/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=