summaryrefslogtreecommitdiffhomepage
path: root/ipn/message_test.go
diff options
context:
space:
mode:
authorDavid Crawshaw <crawshaw@tailscale.com>2021-05-18 13:25:43 -0700
committerDavid Crawshaw <crawshaw@tailscale.com>2021-05-18 13:29:40 -0700
commit0c55ab0ce2a505545a3ea2302d9fa22fb435a843 (patch)
treee7c3117f745e3652f0e71fb4463965af036aa719 /ipn/message_test.go
parent85df1b0fa7d565f5b3deddd825fd08eafbd71632 (diff)
downloadtailscale-crawshaw/newbackendserver.tar.xz
tailscale-crawshaw/newbackendserver.zip
ipn: allow b to be nil in NewBackendServercrawshaw/newbackendserver
A couple of code paths in ipnserver use a NewBackendServer with a nil backend just to call the callback with an encapsulated error message. This covers a panic case seen in logs. For #1920 Signed-off-by: David Crawshaw <crawshaw@tailscale.com>
Diffstat (limited to 'ipn/message_test.go')
-rw-r--r--ipn/message_test.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/ipn/message_test.go b/ipn/message_test.go
index 79c4a76b6..194ac3b89 100644
--- a/ipn/message_test.go
+++ b/ipn/message_test.go
@@ -187,3 +187,17 @@ func TestClientServer(t *testing.T) {
})
flushUntil(Running)
}
+
+func TestNilBackend(t *testing.T) {
+ var called *Notify
+ bs := NewBackendServer(t.Logf, nil, func(n Notify) {
+ called = &n
+ })
+ bs.SendErrorMessage("Danger, Will Robinson!")
+ if called == nil {
+ t.Errorf("expect callback to be called, wasn't")
+ }
+ if called.ErrMessage == nil || *called.ErrMessage != "Danger, Will Robinson!" {
+ t.Errorf("callback got wrong error: %v", called.ErrMessage)
+ }
+}