diff --git a/.travis.yml b/.travis.yml index 9de88108d..87bb798e1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,10 +5,7 @@ services: - docker go: - - "1.12" - - "1.13" - "1.14" - - "stable" env: - MAKE_TASK=test diff --git a/Dockerfile b/Dockerfile index 60fcc19b9..aaecf8ad0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.12-alpine AS builder +FROM golang:1.14-alpine AS builder ARG VERSION='0.0.1-docker' diff --git a/Makefile b/Makefile index bfd09238f..4f8600427 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ all: clean deps test build deps: @echo "$(OK_COLOR)==> Installing dependencies$(NO_COLOR)" @go get -u golang.org/x/lint/golint - @go get -u github.com/cucumber/godog/cmd/godog + @go get -u github.com/cucumber/godog/cmd/godog@v0.10.0 build: @echo "$(OK_COLOR)==> Building... $(NO_COLOR)" diff --git a/features/bootstrap/context_api.go b/features/bootstrap/context_api.go index d5346b8ad..3715293a3 100644 --- a/features/bootstrap/context_api.go +++ b/features/bootstrap/context_api.go @@ -4,16 +4,17 @@ import ( "time" "github.com/cucumber/godog" + "github.com/cucumber/messages-go/v10" "github.com/pkg/errors" "github.com/hellofresh/janus/pkg/api" ) // RegisterAPIContext registers godog suite context for handling API related steps -func RegisterAPIContext(s *godog.Suite, apiRepo api.Repository, ch chan<- api.ConfigurationMessage) { - ctx := &apiContext{apiRepo: apiRepo, ch: ch} +func RegisterAPIContext(ctx *godog.ScenarioContext, apiRepo api.Repository, ch chan<- api.ConfigurationMessage) { + scenarioCtx := &apiContext{apiRepo: apiRepo, ch: ch} - s.BeforeScenario(ctx.clearAPI) + ctx.BeforeScenario(scenarioCtx.clearAPI) } type apiContext struct { @@ -21,7 +22,7 @@ type apiContext struct { ch chan<- api.ConfigurationMessage } -func (c *apiContext) clearAPI(arg interface{}) { +func (c *apiContext) clearAPI(*messages.Pickle) { data, err := c.apiRepo.FindAll() if err != nil { panic(errors.Wrap(err, "Failed to get all registered route specs")) diff --git a/features/bootstrap/context_misc.go b/features/bootstrap/context_misc.go index 8754dfd7b..e0d4d3d5e 100644 --- a/features/bootstrap/context_misc.go +++ b/features/bootstrap/context_misc.go @@ -9,11 +9,11 @@ import ( const durationAWhile = time.Second // RegisterMiscContext registers godog suite context for handling misc steps -func RegisterMiscContext(s *godog.Suite) { - ctx := &miscContext{} +func RegisterMiscContext(ctx *godog.ScenarioContext) { + scenarioCtx := &miscContext{} - s.Step(`^I wait for a while$`, ctx.iWaitForAWhile) - s.Step(`^I wait for "([^"]*)"$`, ctx.iWaitFor) + ctx.Step(`^I wait for a while$`, scenarioCtx.iWaitForAWhile) + ctx.Step(`^I wait for "([^"]*)"$`, scenarioCtx.iWaitFor) } type miscContext struct{} diff --git a/features/bootstrap/context_request.go b/features/bootstrap/context_request.go index c83faf5d8..c53e120c5 100644 --- a/features/bootstrap/context_request.go +++ b/features/bootstrap/context_request.go @@ -10,7 +10,7 @@ import ( "time" "github.com/cucumber/godog" - "github.com/cucumber/godog/gherkin" + "github.com/cucumber/messages-go/v10" jwtGo "github.com/dgrijalva/jwt-go" "github.com/tidwall/gjson" @@ -23,8 +23,8 @@ const ( ) // RegisterRequestContext registers godog suite context for handling HTTP-requests related steps -func RegisterRequestContext(s *godog.Suite, port, apiPort, portSecondary, apiPortSecondary int, adminCred config.Credentials) { - ctx := &requestContext{ +func RegisterRequestContext(ctx *godog.ScenarioContext, port, apiPort, portSecondary, apiPortSecondary int, adminCred config.Credentials) { + scenarioCtx := &requestContext{ port: port, apiPort: apiPort, portSecondary: portSecondary, @@ -32,24 +32,24 @@ func RegisterRequestContext(s *godog.Suite, port, apiPort, portSecondary, apiPor adminCred: adminCred, } - ctx.requestHeaders = make(http.Header) + scenarioCtx.requestHeaders = make(http.Header) - s.Step(`^I request "([^"]*)" path with "([^"]*)" method$`, ctx.iRequestPathWithMethod) - s.Step(`^I request "([^"]*)" API path with "([^"]*)" method$`, ctx.iRequestAPIPathWithMethod) - s.Step(`^I request "([^"]*)" secondary path with "([^"]*)" method$`, ctx.iRequestSecondaryPathWithMethod) - s.Step(`^I request "([^"]*)" secondary API path with "([^"]*)" method$`, ctx.iRequestSecondaryAPIPathWithMethod) - s.Step(`^I should receive (\d+) response code$`, ctx.iShouldReceiveResponseCode) - s.Step(`^header "([^"]*)" should be "([^"]*)"$`, ctx.headerShouldBe) - s.Step(`^header "([^"]*)" should start with "([^"]*)"$`, ctx.headerShouldStartWith) - s.Step(`^the response should contain "([^"]*)"$`, ctx.responseShouldContain) - s.Step(`^response JSON body has "([^"]*)" path with value \'([^']*)\'$`, ctx.responseJSONBodyHasPathWithValue) - s.Step(`^response JSON body has "([^"]*)" path and is an array of length (\d+)$`, ctx.responseJSONBodyHasPathIsAnArrayOfLenght) - s.Step(`^response JSON body has "([^"]*)" path`, ctx.responseJSONBodyHasPath) - s.Step(`^response JSON body is an array of length (\d+)$`, ctx.responseJSONBodyIsAnArrayOfLength) - s.Step(`^request JSON payload:$`, ctx.requestJSONPayload) - s.Step(`^request header "([^"]*)" is set to "([^"]*)"$`, ctx.requestHeaderIsSetTo) - s.Step(`^request JWT token is not set$`, ctx.requestJWTTokenIsNotSet) - s.Step(`^request JWT token is valid admin token$`, ctx.requestJWTTokenIsValidAdminToken) + ctx.Step(`^I request "([^"]*)" path with "([^"]*)" method$`, scenarioCtx.iRequestPathWithMethod) + ctx.Step(`^I request "([^"]*)" API path with "([^"]*)" method$`, scenarioCtx.iRequestAPIPathWithMethod) + ctx.Step(`^I request "([^"]*)" secondary path with "([^"]*)" method$`, scenarioCtx.iRequestSecondaryPathWithMethod) + ctx.Step(`^I request "([^"]*)" secondary API path with "([^"]*)" method$`, scenarioCtx.iRequestSecondaryAPIPathWithMethod) + ctx.Step(`^I should receive (\d+) response code$`, scenarioCtx.iShouldReceiveResponseCode) + ctx.Step(`^header "([^"]*)" should be "([^"]*)"$`, scenarioCtx.headerShouldBe) + ctx.Step(`^header "([^"]*)" should start with "([^"]*)"$`, scenarioCtx.headerShouldStartWith) + ctx.Step(`^the response should contain "([^"]*)"$`, scenarioCtx.responseShouldContain) + ctx.Step(`^response JSON body has "([^"]*)" path with value \'([^']*)\'$`, scenarioCtx.responseJSONBodyHasPathWithValue) + ctx.Step(`^response JSON body has "([^"]*)" path and is an array of length (\d+)$`, scenarioCtx.responseJSONBodyHasPathIsAnArrayOfLenght) + ctx.Step(`^response JSON body has "([^"]*)" path`, scenarioCtx.responseJSONBodyHasPath) + ctx.Step(`^response JSON body is an array of length (\d+)$`, scenarioCtx.responseJSONBodyIsAnArrayOfLength) + ctx.Step(`^request JSON payload:$`, scenarioCtx.requestJSONPayload) + ctx.Step(`^request header "([^"]*)" is set to "([^"]*)"$`, scenarioCtx.requestHeaderIsSetTo) + ctx.Step(`^request JWT token is not set$`, scenarioCtx.requestJWTTokenIsNotSet) + ctx.Step(`^request JWT token is valid admin token$`, scenarioCtx.requestJWTTokenIsValidAdminToken) } type requestContext struct { @@ -217,7 +217,7 @@ func (c *requestContext) responseJSONBodyIsAnArrayOfLength(length int) error { return nil } -func (c *requestContext) requestJSONPayload(body *gherkin.DocString) error { +func (c *requestContext) requestJSONPayload(body *messages.PickleStepArgument_PickleDocString) error { c.requestBody = bytes.NewBufferString(body.Content) return nil } diff --git a/go.mod b/go.mod index 8e7f9182a..87a4a5cdb 100644 --- a/go.mod +++ b/go.mod @@ -11,8 +11,8 @@ require ( github.com/asaskevich/govalidator v0.0.0-20171111151018-521b25f4b05f github.com/bshuster-repo/logrus-logstash-hook v0.4.1 // indirect github.com/cactus/go-statsd-client v3.1.1+incompatible // indirect - github.com/cucumber/godog v0.8.1 - github.com/davecgh/go-spew v1.1.0 // indirect + github.com/cucumber/godog v0.10.0 + github.com/cucumber/messages-go/v10 v10.0.3 github.com/dgrijalva/jwt-go v3.2.0+incompatible github.com/felixge/httpsnoop v1.0.0 github.com/fiam/gounidecode v0.0.0-20150629112515-8deddbd03fec // indirect @@ -20,8 +20,7 @@ require ( github.com/globalsign/mgo v0.0.0-20180615134936-113d3961e731 github.com/go-chi/chi v3.3.2+incompatible github.com/go-redis/redis v6.12.0+incompatible - github.com/gofrs/uuid v3.2.0+incompatible - github.com/gogo/protobuf v1.2.1 // indirect + github.com/gofrs/uuid v3.3.0+incompatible github.com/google/go-github v17.0.0+incompatible github.com/google/go-querystring v0.0.0-20170111101155-53e6ce116135 // indirect github.com/hashicorp/hcl v0.0.0-20171017181929-23c074d0eceb // indirect @@ -53,7 +52,7 @@ require ( github.com/spf13/jwalterweatherman v0.0.0-20180109140146-7c0cea34c8ec // indirect github.com/spf13/pflag v1.0.0 // indirect github.com/spf13/viper v1.0.0 - github.com/stretchr/testify v1.2.2 + github.com/stretchr/testify v1.6.1 github.com/tidwall/gjson v1.1.0 github.com/tidwall/match v1.0.0 // indirect github.com/ulule/limiter v2.2.2+incompatible @@ -69,6 +68,7 @@ require ( gopkg.in/alexcesaro/statsd.v2 v2.0.0 // indirect gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2 // indirect gopkg.in/gemnasium/logrus-graylog-hook.v2 v2.0.6 // indirect + gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 // indirect ) replace git.apache.org/thrift.git => github.com/apache/thrift v0.12.0 diff --git a/go.sum b/go.sum index e1427bda8..a31154ea8 100644 --- a/go.sum +++ b/go.sum @@ -12,16 +12,27 @@ github.com/apache/thrift v0.12.0 h1:pODnxUFNcjP9UTLZGTdeh+j16A8lJbRvD3rOtrk/7bs= github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= github.com/asaskevich/govalidator v0.0.0-20171111151018-521b25f4b05f h1:xHxhygLkJBQaXZ7H0JUpmqK/gfKO2DZXB7gAKT6bbBs= github.com/asaskevich/govalidator v0.0.0-20171111151018-521b25f4b05f/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= +github.com/aslakhellesoy/gox v1.0.100/go.mod h1:AJl542QsKKG96COVsv0N74HHzVQgDIQPceVUh1aeU2M= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 h1:xJ4a3vCFaGF/jqvzLMYoU8P317H5OQ+Via4RmuPwCS0= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/bshuster-repo/logrus-logstash-hook v0.4.1 h1:pgAtgj+A31JBVtEHu2uHuEx0n+2ukqUJnS2vVe5pQNA= github.com/bshuster-repo/logrus-logstash-hook v0.4.1/go.mod h1:zsTqEiSzDgAa/8GZR7E1qaXrhYNDKBYy5/dWPTIflbk= github.com/cactus/go-statsd-client v3.1.1+incompatible h1:p97okCU2aaeSxQ6KzMdGEwQkiGBMys71/J0XWoirbJY= github.com/cactus/go-statsd-client v3.1.1+incompatible/go.mod h1:cMRcwZDklk7hXp+Law83urTHUiHMzCev/r4JMYr/zU0= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/cucumber/gherkin-go/v11 v11.0.0 h1:cwVwN1Qn2VRSfHZNLEh5x00tPBmZcjATBWDpxsR5Xug= +github.com/cucumber/gherkin-go/v11 v11.0.0/go.mod h1:CX33k2XU2qog4e+TFjOValoq6mIUq0DmVccZs238R9w= github.com/cucumber/godog v0.8.1 h1:lVb+X41I4YDreE+ibZ50bdXmySxgRviYFgKY6Aw4XE8= github.com/cucumber/godog v0.8.1/go.mod h1:vSh3r/lM+psC1BPXvdkSEuNjmXfpVqrMGYAElF6hxnA= +github.com/cucumber/godog v0.10.0 h1:W01u1+o8bRpgqJRLrclN3iAanU1jAao+TwOMoSV9g1Y= +github.com/cucumber/godog v0.10.0/go.mod h1:0Q+MOUg8Z9AhzLV+nNMbThQ2x1b17yYwGyahApTLjJA= +github.com/cucumber/messages-go/v10 v10.0.1/go.mod h1:kA5T38CBlBbYLU12TIrJ4fk4wSkVVOgyh7Enyy8WnSg= +github.com/cucumber/messages-go/v10 v10.0.3 h1:m/9SD/K/A15WP7i1aemIv7cwvUw+viS51Ui5HBw1cdE= +github.com/cucumber/messages-go/v10 v10.0.3/go.mod h1:9jMZ2Y8ZxjLY6TG2+x344nt5rXstVVDYSdS5ySfI1WY= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= 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/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/felixge/httpsnoop v1.0.0 h1:gh8fMGz0rlOv/1WmRZm7OgncIOTsAj21iNJot48omJQ= @@ -39,8 +50,12 @@ github.com/go-redis/redis v6.12.0+incompatible h1:s+64XI+z/RXqGHz2fQSgRJOEwqqSXe github.com/go-redis/redis v6.12.0+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA= github.com/gofrs/uuid v3.2.0+incompatible h1:y12jRkkFxsd7GpqdSZ+/KCs/fJbqpEXSGd4+jfEaewE= github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= +github.com/gofrs/uuid v3.3.0+incompatible h1:8K4tyRfvU1CYPgJsveYFQMhpFd/wXNM7iK6rR7UHz84= +github.com/gofrs/uuid v3.3.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/gogo/protobuf v1.2.1 h1:/s5zKNz0uPFCZ5hddgPdo2TK2TVrUNMn0OOX8/aZMTE= github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= +github.com/gogo/protobuf v1.3.1 h1:DqDEcV5aeaTmdFBePNpYsp3FlcVH/2ISVVM9Qf8PSls= +github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -53,6 +68,15 @@ github.com/google/go-querystring v0.0.0-20170111101155-53e6ce116135/go.mod h1:od github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/grpc-ecosystem/grpc-gateway v1.5.0/go.mod h1:RSKVYQBd5MCa4OVpNdGskqpgL2+G+NZTnrVHpWWfpdw= +github.com/hashicorp/go-immutable-radix v1.2.0 h1:l6UW37iCXwZkZoAbEYnptSHVE/cQ5bOTPYG5W3vf9+8= +github.com/hashicorp/go-immutable-radix v1.2.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= +github.com/hashicorp/go-memdb v1.2.1 h1:wI9btDjYUOJJHTCnRlAG/TkRyD/ij7meJMrLK9X31Cc= +github.com/hashicorp/go-memdb v1.2.1/go.mod h1:OSvLJ662Jim8hMM+gWGyhktyWk2xPCnWMc7DWIqtkGA= +github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-version v1.0.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc= +github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= github.com/hashicorp/hcl v0.0.0-20171017181929-23c074d0eceb h1:1OvvPvZkn/yCQ3xBcM8y4020wdkMXPHLB4+NfoGWh4U= github.com/hashicorp/hcl v0.0.0-20171017181929-23c074d0eceb/go.mod h1:oZtUIOe8dh44I2q6ScRibXws4Ajl+d+nod3AaR9vL5w= github.com/hellofresh/health-go v1.2.6 h1:qL3H7n3Vjz1tR9F6yvs5jO5IKh0e7ptIt+/1aDNLETg= @@ -72,15 +96,22 @@ github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfV github.com/kelseyhightower/envconfig v1.3.0 h1:IvRS4f2VcIQy6j4ORGIf9145T/AsUB+oY8LyvN8BXNM= github.com/kelseyhightower/envconfig v1.3.0/go.mod h1:cccZRl6mQpaq41TPp5QxidR+Sa3axMbJDNb//FQX6Gg= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= +github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/magiconair/properties v1.7.4 h1:UVo0TkHGd4lQSN1dVDzs9URCIgReuSIcCXpAVB9nZ80= github.com/magiconair/properties v1.7.4/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/mitchellh/go-homedir v0.0.0-20161203194507-b8bc1bf76747 h1:eQox4Rh4ewJF+mqYPxCkmBAirRnPaHEB26UkNuPyjlk= github.com/mitchellh/go-homedir v0.0.0-20161203194507-b8bc1bf76747/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= github.com/mitchellh/mapstructure v0.0.0-20180111000720-b4575eea38cc h1:5T6hzGUO5OrL6MdYXYoLQtRWJDDgjdlOVBn9mIqGY1g= github.com/mitchellh/mapstructure v0.0.0-20180111000720-b4575eea38cc/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.9.0 h1:SZjF721BByVj8QH636/8S2DnX4n0Re3SteMmw3N+tzc= github.com/onsi/ginkgo v1.9.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= @@ -128,8 +159,13 @@ github.com/spf13/pflag v1.0.0 h1:oaPbdDe/x0UncahuwiPxW1GYJyilRAdsPnq3e1yaPcI= github.com/spf13/pflag v1.0.0/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/viper v1.0.0 h1:RUA/ghS2i64rlnn4ydTfblY8Og8QzcPtCcHvgMn+w/I= github.com/spf13/viper v1.0.0/go.mod h1:A8kyI5cUJhb8N+3pkfONlcEcZbueH6nhAm0Fq7SrnBM= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/tidwall/gjson v1.1.0 h1:/7OBSUzFP8NhuzLlHg0vETJrRL02C++0ql5uSY3DITs= github.com/tidwall/gjson v1.1.0/go.mod h1:c/nTNbUr0E0OrXEhq1pwa8iEgc2DOt4ZZqAt1HtCkPA= github.com/tidwall/match v1.0.0 h1:Ym1EcFkp+UQ4ptxfWlW+iMdq5cPH5nEuGzdf/Pb7VmI= @@ -178,6 +214,7 @@ 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-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7 h1:EBZoQjiKKPaLbPrbpssUfuHtwM6KV/vb4U85g/cigFY= @@ -199,6 +236,8 @@ gopkg.in/alexcesaro/statsd.v2 v2.0.0 h1:FXkZSCZIH17vLCO5sO2UucTHsH9pc+17F6pl3JVC gopkg.in/alexcesaro/statsd.v2 v2.0.0/go.mod h1:i0ubccKGzBVNBpdGV5MocxyA/XlLUJzA7SLonnE4drU= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2 h1:OAj3g0cR6Dx/R07QgQe8wkA9RNjB2u4i700xBkIT4e0= @@ -209,3 +248,10 @@ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkep gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 h1:tQIYjPdBoyREyB9XMu+nnTclpTYkz2zFM+lzLJFO4gQ= +gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/godog_test.go b/godog_test.go deleted file mode 100644 index 5163b3a28..000000000 --- a/godog_test.go +++ /dev/null @@ -1,70 +0,0 @@ -package main - -import ( - "context" - "net/url" - "os" - "strconv" - "testing" - - "github.com/cucumber/godog" - "github.com/stretchr/testify/assert" - - "github.com/hellofresh/janus/features/bootstrap" - "github.com/hellofresh/janus/pkg/api" - "github.com/hellofresh/janus/pkg/config" -) - -func FeatureContext(s *godog.Suite) { - c, err := config.LoadEnv() - if nil != err { - panic(err) - } - - var apiRepo api.Repository - - dsnURL, err := url.Parse(c.Database.DSN) - if nil != err { - panic(err) - } - - switch dsnURL.Scheme { - case "mongodb": - apiRepo, err = api.NewMongoAppRepository(c.Database.DSN, c.BackendFlushInterval) - if err != nil { - panic(err) - } - case "file": - var apiPath = dsnURL.Path + "/apis" - - apiRepo, err = api.NewFileSystemRepository(apiPath) - if err != nil { - panic(err) - } - default: - panic("invalid database") - } - - portSecondary, err := strconv.Atoi(os.Getenv("PORT_SECONDARY")) - if nil != err { - panic(err) - } - - apiPortSecondary, err := strconv.Atoi(os.Getenv("API_PORT_SECONDARY")) - if nil != err { - panic(err) - } - - ch := make(chan api.ConfigurationMessage, 100) - if listener, ok := apiRepo.(api.Listener); ok { - listener.Listen(context.Background(), ch) - } - - bootstrap.RegisterRequestContext(s, c.Port, c.Web.Port, portSecondary, apiPortSecondary, c.Web.Credentials) - bootstrap.RegisterAPIContext(s, apiRepo, ch) - bootstrap.RegisterMiscContext(s) -} - -func Test_Fake(t *testing.T) { - assert.True(t, true) -} diff --git a/main_test.go b/main_test.go new file mode 100644 index 000000000..6b976b6f9 --- /dev/null +++ b/main_test.go @@ -0,0 +1,82 @@ +package main + +import ( + "context" + "net/url" + "os" + "strconv" + "testing" + + "github.com/cucumber/godog" + "github.com/stretchr/testify/assert" + + "github.com/hellofresh/janus/features/bootstrap" + "github.com/hellofresh/janus/pkg/api" + "github.com/hellofresh/janus/pkg/config" +) + +var ( + apiRepo api.Repository + cfg *config.Specification + portSecondary int + apiPortSecondary int + cfgChan chan api.ConfigurationMessage +) + +func InitializeTestSuite(ctx *godog.TestSuiteContext) { + var err error + + ctx.BeforeSuite(func() { + cfg, err = config.LoadEnv() + if err != nil { + panic(err) + } + + dsnURL, err := url.Parse(cfg.Database.DSN) + if nil != err { + panic(err) + } + + switch dsnURL.Scheme { + case "mongodb": + apiRepo, err = api.NewMongoAppRepository(cfg.Database.DSN, cfg.BackendFlushInterval) + if err != nil { + panic(err) + } + case "file": + var apiPath = dsnURL.Path + "/apis" + + apiRepo, err = api.NewFileSystemRepository(apiPath) + if err != nil { + panic(err) + } + default: + panic("invalid database") + } + + portSecondary, err = strconv.Atoi(os.Getenv("PORT_SECONDARY")) + if err != nil { + panic(err) + } + + apiPortSecondary, err = strconv.Atoi(os.Getenv("API_PORT_SECONDARY")) + if err != nil { + panic(err) + } + + cfgChan = make(chan api.ConfigurationMessage, 100) + if listener, ok := apiRepo.(api.Listener); ok { + listener.Listen(context.Background(), cfgChan) + } + }) +} + +func InitializeScenario(ctx *godog.ScenarioContext) { + bootstrap.RegisterRequestContext(ctx, cfg.Port, cfg.Web.Port, portSecondary, apiPortSecondary, cfg.Web.Credentials) + bootstrap.RegisterAPIContext(ctx, apiRepo, cfgChan) + bootstrap.RegisterMiscContext(ctx) +} + +func Test_Fake(t *testing.T) { + assert.True(t, true) +}