Skip to content

Commit

Permalink
E2E testing related improvements for release rollout rest API
Browse files Browse the repository at this point in the history
  • Loading branch information
adamluzsi committed Aug 11, 2021
1 parent 6264890 commit bfe5f98
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 22 deletions.
6 changes: 3 additions & 3 deletions domains/release/Rollout.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import (
type Rollout struct {
ID string `ext:"ID"`
// FlagID is the release flag id to which the rolloutBase belongs
FlagID string
FlagID string `json:"flag_id"`
// EnvironmentID is the deployment environment id
DeploymentEnvironmentID string
DeploymentEnvironmentID string `json:"env_id"`
// Plan holds the composited rule set about the pilot participation decision logic.
Plan RolloutDefinition `json:"plan,omitempty"`
}
Expand Down Expand Up @@ -538,7 +538,7 @@ type rolloutView struct {
// FlagID is the release flag id to which the rolloutBase belongs
FlagID string `json:"flag_id"`
// EnvironmentID is the deployment environment id
DeploymentEnvironmentID string `json:"deployment_environment_id"`
DeploymentEnvironmentID string `json:"env_id"`
// Plan holds the composited rule set about the pilot participation decision logic.
RolloutPlan RolloutDefinitionView `json:"plan"`
}
Expand Down
20 changes: 11 additions & 9 deletions external/interface/httpintf/httpapi/ReleaseRolloutController.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package httpapi
import (
"context"
"encoding/json"
"fmt"
"net/http"

"github.com/adamluzsi/frameless/iterators"
Expand Down Expand Up @@ -56,9 +57,9 @@ type CreateReleaseRolloutRequest struct {
// required: true
// in: body
Body struct {
EnvironmentID string `json:"envID"`
FlagID string `json:"flagID"`
Rollout struct {
Rollout struct {
EnvironmentID string `json:"env_id"`
FlagID string `json:"flag_id"`
// Plan holds the composited rule set about the pilot participation decision logic.
//
// required: true
Expand Down Expand Up @@ -108,20 +109,21 @@ func (ctrl ReleaseRolloutController) Create(w http.ResponseWriter, r *http.Reque
defer r.Body.Close() // ignorable

type Payload struct {
Rollout release.Rollout `json:"rollout"`
EnvironmentID string `json:"envID"`
FlagID string `json:"flagID"`
Rollout release.Rollout `json:"rollout"`
}
var p Payload

if handleError(w, decoder.Decode(&p), http.StatusBadRequest) {
return
}

p.Rollout.FlagID = p.FlagID
p.Rollout.DeploymentEnvironmentID = p.EnvironmentID
rr := p.Rollout
ctx := r.Context()
rrs := ctrl.UseCases.Storage.ReleaseRollout(ctx)
err := rrs.Create(ctx, &rr)

if ctrl.handleFlagValidationError(w, ctrl.UseCases.Storage.ReleaseRollout(r.Context()).Create(r.Context(), &p.Rollout)) {
if ctrl.handleFlagValidationError(w, err) {
fmt.Println(`????`, err, fmt.Sprintf("%#v", rr))
return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,15 @@ func SpecReleaseRolloutControllerCreate(s *testcase.Spec) {
return &r
})

Debug(s)

Body.Let(s, func(t *testcase.T) interface{} {
r := sh.GetReleaseRollout(t, rollout.Name)
var req httpapi.CreateReleaseRolloutRequest
t.Log(r)
req.Body.Rollout.Plan = release.RolloutDefinitionView{Definition: r.Plan}
req.Body.EnvironmentID = sh.ExampleDeploymentEnvironment(t).ID
req.Body.FlagID = sh.ExampleReleaseFlag(t).ID
req.Body.Rollout.EnvironmentID = sh.ExampleDeploymentEnvironment(t).ID
req.Body.Rollout.FlagID = sh.ExampleReleaseFlag(t).ID
return req.Body
})

Expand Down
16 changes: 8 additions & 8 deletions external/interface/httpintf/swagger/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -663,20 +663,20 @@
"schema": {
"type": "object",
"properties": {
"envID": {
"type": "string",
"x-go-name": "EnvironmentID"
},
"flagID": {
"type": "string",
"x-go-name": "FlagID"
},
"rollout": {
"type": "object",
"required": [
"plan"
],
"properties": {
"env_id": {
"type": "string",
"x-go-name": "EnvironmentID"
},
"flag_id": {
"type": "string",
"x-go-name": "FlagID"
},
"plan": {
"description": "Plan holds the composited rule set about the pilot participation decision logic.",
"type": "object",
Expand Down

0 comments on commit bfe5f98

Please sign in to comment.