Skip to content

Commit

Permalink
feat: Add runtime incident policy sorting in tests
Browse files Browse the repository at this point in the history
Signed-off-by: Bezalel Brandwine <[email protected]>
  • Loading branch information
Bezalel Brandwine committed Jul 31, 2024
1 parent eab3539 commit 11d7ee2
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
3 changes: 1 addition & 2 deletions routes/v1/runtime_incident_policy/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ func AddRoutes(g *gin.Engine) {
WithValidatePostUniqueName(false).
WithValidatePutGUID(true).
WithValidatePostMandatoryName(true).
WithV2ListSearch(true).
WithValidatePutUniqueName(true)
WithV2ListSearch(true)

handlers.AddRoutes(g, routerOptionsBuilder.Get()...)
}
10 changes: 10 additions & 0 deletions service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ var runtimeIncidentPolicyReq1 []byte
//go:embed test_data/runtimeIncidentPolicyReq2.json
var runtimeIncidentPolicyReq2 []byte

//go:embed test_data/runtimeIncidentPolicyReq3.json
var runtimeIncidentPolicyReq3 []byte

var newClusterCompareFilter = cmp.FilterPath(func(p cmp.Path) bool {
switch p.String() {
case "PortalBase.GUID", "SubscriptionDate", "LastLoginDate", "PortalBase.UpdatedTime", "ExpirationDate":
Expand Down Expand Up @@ -2131,6 +2134,13 @@ func (suite *MainTestSuite) TestRuntimeIncidentPolicies() {
suite.NotNil(doc.GUID)
suite.Equal("Anomaly", doc.Name[:7])
}
// test sort by scope
w = suite.doRequest(http.MethodPost, consts.RuntimeIncidentPolicyPath+"/query", runtimeIncidentPolicyReq3)
suite.Equal(http.StatusOK, w.Code)
_, err = decodeResponse[armotypes.V2ListResponseGeneric[[]*kdr.IncidentPolicy]](w)
if err != nil {
suite.FailNow(err.Error())
}
}

func (suite *MainTestSuite) TestIntegrationReference() {
Expand Down
33 changes: 33 additions & 0 deletions test_data/runtimeIncidentPolicyReq3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"pageSize": 100,
"pageNum": 0,
"orderBy": "scope.designators.cluster:asc,scope.designators.namespace:asc,scope.designators.kind:asc,scope.designators.name:asc",
"innerFilters": [
{
"enabled": "true",
"managedRuleSetIDs": "c9fe6345-c393-4595-bd7b-22110dbafe61",
"ruleSetType": "Managed",
"scope.designators.cluster": "gke_elated-pottery-310110_us-central1-c_bez-longrun-3,|missing",
"scope.designators.kind": "Deployment,|missing",
"scope.designators.labels": ",|missing",
"scope.designators.name": "redis-sleep,|missing",
"scope.designators.namespace": "systest-ns-o9zz,|missing",
"scope.riskFactors": "risk1,|missing"
},
{
"enabled": "true",
"incidentTypeIDs": "I013,|missing",
"ruleSetType": "Custom",
"scope.designators.cluster": "gke_elated-pottery-310110_us-central1-c_bez-longrun-3,|missing",
"scope.designators.kind": "Deployment,|missing",
"scope.designators.labels": ",|missing",
"scope.designators.name": "redis-sleep,|missing",
"scope.designators.namespace": "systest-ns-o9zz,|missing",
"scope.riskFactors": "|missing"
}
],
"includeFields": [
"guid",
"name"
]
}

0 comments on commit 11d7ee2

Please sign in to comment.