mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-20 09:57:31 +00:00
tailcfg: flesh out some docs on MapResponse, clarify slices w/ omitempty
Updates #cleanup Change-Id: If4caf9d00529edc09ae7af9cc70f6ba0ade38378 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:

committed by
Brad Fitzpatrick

parent
a5ffd5e7c3
commit
70ea073478
@@ -705,3 +705,24 @@ func TestCurrentCapabilityVersion(t *testing.T) {
|
||||
t.Errorf("CurrentCapabilityVersion = %d; want %d", CurrentCapabilityVersion, max)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUnmarshalHealth(t *testing.T) {
|
||||
tests := []struct {
|
||||
in string // MapResponse JSON
|
||||
want []string // MapResponse.Health wanted value post-unmarshal
|
||||
}{
|
||||
{in: `{}`},
|
||||
{in: `{"Health":null}`},
|
||||
{in: `{"Health":[]}`, want: []string{}},
|
||||
{in: `{"Health":["bad"]}`, want: []string{"bad"}},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
var mr MapResponse
|
||||
if err := json.Unmarshal([]byte(tt.in), &mr); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !reflect.DeepEqual(mr.Health, tt.want) {
|
||||
t.Errorf("for %#q: got %v; want %v", tt.in, mr.Health, tt.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user