Skip to content

Commit

Permalink
fix: api regression breaking blocky blocking disable (#1373)
Browse files Browse the repository at this point in the history
* fix: Corrects ability to disable all blocking from the CLI by not providing any groups

* fix: More appropriately correct the issue preventing disabled blocking directly when parsing parameters

* Use the same length logic previously seen

* Code reviewcomments

* Remove redundant check

* Revert nil check removal; Removing this broke tests
  • Loading branch information
BenMcH committed Feb 10, 2024
1 parent 9f633f1 commit fe84ab8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion api/api_interface_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func (i *OpenAPIInterfaceImpl) DisableBlocking(ctx context.Context,
}
}

if request.Params.Groups != nil {
if request.Params.Groups != nil && len(*request.Params.Groups) > 0 {
groups = strings.Split(*request.Params.Groups, ",")
}

Expand Down
17 changes: 17 additions & 0 deletions api/api_interface_impl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,23 @@ var _ = Describe("API implementation tests", func() {

Describe("Control blocking status via API", func() {
When("Disable blocking is called", func() {
It("should return a success when receiving no groups", func() {
var emptySlice []string
blockingControlMock.On("DisableBlocking", 3*time.Second, emptySlice).Return(nil)
duration := "3s"
grroups := ""

resp, err := sut.DisableBlocking(ctx, DisableBlockingRequestObject{
Params: DisableBlockingParams{
Duration: &duration,
Groups: &grroups,
},
})
Expect(err).Should(Succeed())
var resp200 DisableBlocking200Response
Expect(resp).Should(BeAssignableToTypeOf(resp200))
})

It("should return 200 on success", func() {
blockingControlMock.On("DisableBlocking", 3*time.Second, []string{"gr1", "gr2"}).Return(nil)
duration := "3s"
Expand Down

0 comments on commit fe84ab8

Please sign in to comment.