mirror of
https://github.com/tailscale/tailscale.git
synced 2025-12-07 10:22:06 +01:00
ipn: fix the string representation of an empty ipn.Notify
Before: `ipn.Notify}`
After: `ipn.Notify{}`
Updates #cleanup
Signed-off-by: Alex Chan <alexc@tailscale.com>
This commit is contained in:
parent
2015ce4081
commit
84659b1dc6
@ -205,7 +205,11 @@ func (n Notify) String() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
s := sb.String()
|
s := sb.String()
|
||||||
return s[0:len(s)-1] + "}"
|
if s == "Notify{" {
|
||||||
|
return "Notify{}"
|
||||||
|
} else {
|
||||||
|
return s[0:len(s)-1] + "}"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// PartialFile represents an in-progress incoming file transfer.
|
// PartialFile represents an in-progress incoming file transfer.
|
||||||
|
|||||||
42
ipn/backend_test.go
Normal file
42
ipn/backend_test.go
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
// Copyright (c) Tailscale Inc & AUTHORS
|
||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
|
||||||
|
package ipn
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"tailscale.com/health"
|
||||||
|
"tailscale.com/types/empty"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestNotifyString(t *testing.T) {
|
||||||
|
for _, tt := range []struct {
|
||||||
|
name string
|
||||||
|
value Notify
|
||||||
|
expected string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "notify-empty",
|
||||||
|
value: Notify{},
|
||||||
|
expected: "Notify{}",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "notify-with-login-finished",
|
||||||
|
value: Notify{LoginFinished: &empty.Message{}},
|
||||||
|
expected: "Notify{LoginFinished}",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "notify-with-multiple-fields",
|
||||||
|
value: Notify{LoginFinished: &empty.Message{}, Health: &health.State{}},
|
||||||
|
expected: "Notify{LoginFinished Health{...}}",
|
||||||
|
},
|
||||||
|
} {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
actual := tt.value.String()
|
||||||
|
if actual != tt.expected {
|
||||||
|
t.Fatalf("expected=%q, actual=%q", tt.expected, actual)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user