diff --git a/internal/api/dhcp/digest_test.go b/internal/api/dhcp/digest_test.go index fe5dd29..f8a0510 100644 --- a/internal/api/dhcp/digest_test.go +++ b/internal/api/dhcp/digest_test.go @@ -1,6 +1,8 @@ package dhcpapi import ( + "encoding/json" + "strings" "testing" ) @@ -171,3 +173,13 @@ func TestCanonical_SortsHostsByMAC(t *testing.T) { t.Errorf("hosts = %v, want sorted by mac", got.Hosts) } } + +func TestResponse_ServedIsAlwaysOnTheWire(t *testing.T) { + raw, err := json.Marshal(Response{OK: true, Served: false}) + if err != nil { + t.Fatalf("Marshal: %v", err) + } + if !strings.Contains(string(raw), `"served":false`) { + t.Errorf("response = %s, want an explicit served:false — omitting it makes \"not served\" indistinguishable from a missing field when probing by hand", raw) + } +} diff --git a/internal/api/dhcp/models.go b/internal/api/dhcp/models.go index b0268cf..d454194 100644 --- a/internal/api/dhcp/models.go +++ b/internal/api/dhcp/models.go @@ -54,5 +54,5 @@ type Response struct { State *State `json:"state,omitempty"` Digest string `json:"digest,omitempty"` Lease *Lease `json:"lease,omitempty"` - Served bool `json:"served,omitempty"` + Served bool `json:"served"` }