Skip to content

Commit

Permalink
BUG/MINOR: Fix option redispatch serialization
Browse files Browse the repository at this point in the history
When the redispatch interval is set to zero, remove
the option from the configuration.
  • Loading branch information
oliwer committed Feb 17, 2025
1 parent ccf6d0e commit 39a6922
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions configuration/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -2376,6 +2376,9 @@ func (s *SectionObject) redispatch(field reflect.Value) error {
if *br.Enabled == "disabled" {
d.NoOption = true
}
if br.Interval == 0 {
d = nil
}
if err := s.set("option redispatch", d); err != nil {
return err
}
Expand Down
7 changes: 7 additions & 0 deletions test/backend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,10 @@ func TestCreateEditDeleteBackend(t *testing.T) {
{Name: "test_errors_all"},
},
Disabled: true,
Redispatch: &models.Redispatch{
Enabled: misc.StringP("enabled"),
Interval: 0,
},
},
}

Expand All @@ -233,6 +237,9 @@ func TestCreateEditDeleteBackend(t *testing.T) {
t.Error(err.Error())
}

// A redispatch with a zero interval is automatically removed from configuration.
b.Redispatch = nil

var givenJSONB []byte
givenJSONB, err = b.MarshalBinary()
if err != nil {
Expand Down

0 comments on commit 39a6922

Please sign in to comment.