ipn: make Notify.Prefs be a *ipn.PrefsView
It is currently a `ipn.PrefsView` which means when we do a JSON roundtrip,
we go from an invalid Prefs to a valid one.
This makes it a pointer, which fixes the JSON roundtrip.
This was introduced in 0957bc5af2.
Signed-off-by: Maisem Ali <maisem@tailscale.com>
This commit is contained in:
@@ -871,3 +871,22 @@ func TestMaskedPrefsIsEmpty(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestNotifyPrefsJSONRoundtrip(t *testing.T) {
|
||||
var n Notify
|
||||
if n.Prefs != nil && n.Prefs.Valid() {
|
||||
t.Fatal("Prefs should not be valid at start")
|
||||
}
|
||||
b, err := json.Marshal(n)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
var n2 Notify
|
||||
if err := json.Unmarshal(b, &n2); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if n2.Prefs != nil && n2.Prefs.Valid() {
|
||||
t.Fatal("Prefs should not be valid after deserialization")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user