diff --git a/api/turing/api/deployment_controller.go b/api/turing/api/deployment_controller.go index 43517a318..b5022e44e 100644 --- a/api/turing/api/deployment_controller.go +++ b/api/turing/api/deployment_controller.go @@ -153,7 +153,7 @@ func (c RouterDeploymentController) writeDeploymentEvents( // (current version reference, status, endpoint, etc.) are not in the scope of this method. // This method returns the new router endpoint (if successful) and any error. func (c RouterDeploymentController) deployRouterVersion( - ctx context.Context, + _ context.Context, project *mlp.Project, environment *merlin.Environment, routerVersion *models.RouterVersion, diff --git a/api/turing/api/router_versions_api.go b/api/turing/api/router_versions_api.go index b90b5d9d4..8e1b48932 100644 --- a/api/turing/api/router_versions_api.go +++ b/api/turing/api/router_versions_api.go @@ -2,16 +2,15 @@ package api import ( "fmt" - "github.com/caraml-dev/turing/api/turing/webhook" "net/http" - "github.com/caraml-dev/turing/api/turing/service" - mlp "github.com/caraml-dev/mlp/api/client" "github.com/caraml-dev/turing/api/turing/api/request" "github.com/caraml-dev/turing/api/turing/log" "github.com/caraml-dev/turing/api/turing/models" + "github.com/caraml-dev/turing/api/turing/service" + "github.com/caraml-dev/turing/api/turing/webhook" ) type RouterVersionsController struct { diff --git a/api/turing/api/router_versions_api_test.go b/api/turing/api/router_versions_api_test.go index ef723f3a5..6222afa04 100644 --- a/api/turing/api/router_versions_api_test.go +++ b/api/turing/api/router_versions_api_test.go @@ -2,20 +2,21 @@ package api import ( "errors" - "github.com/caraml-dev/turing/api/turing/webhook" - webhookMock "github.com/caraml-dev/turing/api/turing/webhook/mocks" "net/http" "testing" - merlin "github.com/caraml-dev/merlin/client" - mlp "github.com/caraml-dev/mlp/api/client" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" + merlin "github.com/caraml-dev/merlin/client" + mlp "github.com/caraml-dev/mlp/api/client" + "github.com/caraml-dev/turing/api/turing/api/request" "github.com/caraml-dev/turing/api/turing/config" "github.com/caraml-dev/turing/api/turing/models" "github.com/caraml-dev/turing/api/turing/service/mocks" + "github.com/caraml-dev/turing/api/turing/webhook" + webhookMock "github.com/caraml-dev/turing/api/turing/webhook/mocks" routerConfig "github.com/caraml-dev/turing/engines/router/missionctl/config" ) diff --git a/api/turing/api/routers_api.go b/api/turing/api/routers_api.go index d6c07d285..8fb371f5f 100644 --- a/api/turing/api/routers_api.go +++ b/api/turing/api/routers_api.go @@ -203,13 +203,13 @@ func (c RoutersController) UpdateRouter(req *http.Request, vars RequestVars, bod log.Errorf("Error deploying router %s:%s:%d: %v", project.Name, router.Name, routerVersion.Version, err) } - }() - // call webhook for router update event - if errWebhook := c.webhookClient.TriggerWebhooks(ctx, webhook.OnRouterUpdated, router); errWebhook != nil { - log.Warnf("Error triggering webhook for event %s, router id: %d, %v", - webhook.OnRouterUpdated, router.ID, errWebhook) - } + // call webhook for router update event + if errWebhook := c.webhookClient.TriggerWebhooks(ctx, webhook.OnRouterUpdated, router); errWebhook != nil { + log.Warnf("Error triggering webhook for event %s, router id: %d, %v", + webhook.OnRouterUpdated, router.ID, errWebhook) + } + }() return Ok(router) } diff --git a/api/turing/api/routers_api_test.go b/api/turing/api/routers_api_test.go index ac27b582e..20a27201b 100644 --- a/api/turing/api/routers_api_test.go +++ b/api/turing/api/routers_api_test.go @@ -5,17 +5,17 @@ import ( "net/http" "testing" - "github.com/caraml-dev/turing/api/turing/webhook" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/mock" merlin "github.com/caraml-dev/merlin/client" mlp "github.com/caraml-dev/mlp/api/client" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/mock" "github.com/caraml-dev/turing/api/turing/api/request" "github.com/caraml-dev/turing/api/turing/config" "github.com/caraml-dev/turing/api/turing/models" "github.com/caraml-dev/turing/api/turing/service/mocks" + "github.com/caraml-dev/turing/api/turing/webhook" webhookMock "github.com/caraml-dev/turing/api/turing/webhook/mocks" routerConfig "github.com/caraml-dev/turing/engines/router/missionctl/config" ) @@ -468,26 +468,26 @@ func TestUpdateRouter(t *testing.T) { vars: RequestVars{"project_id": {"2"}, "router_id": {"3"}}, expected: InternalServerError("unable to update router", "router config is empty"), }, - //"success": { - // req: &http.Request{}, - // body: &request.CreateOrUpdateRouterRequest{ - // Name: "router4", - // Environment: "dev", - // Config: &request.RouterConfig{ - // ExperimentEngine: &request.ExperimentEngineConfig{ - // Type: "nop", - // }, - // LogConfig: &request.LogConfig{ - // ResultLoggerType: models.NopLogger, - // }, - // }, - // }, - // vars: RequestVars{"project_id": {"2"}, "router_id": {"4"}}, - // expected: &Response{ - // code: 200, - // data: router4, - // }, - //}, + "success": { + req: &http.Request{}, + body: &request.CreateOrUpdateRouterRequest{ + Name: "router4", + Environment: "dev", + Config: &request.RouterConfig{ + ExperimentEngine: &request.ExperimentEngineConfig{ + Type: "nop", + }, + LogConfig: &request.LogConfig{ + ResultLoggerType: models.NopLogger, + }, + }, + }, + vars: RequestVars{"project_id": {"2"}, "router_id": {"4"}}, + expected: &Response{ + code: 200, + data: router4, + }, + }, } // Run tests