types/logid: simplify implementation (#7415)
Share the same underlying implementation for both PrivateID and PublicID. For the shared methods, declare them in the same order. Only keep documentation on methods without obvious meaning. Signed-off-by: Joe Tsai <joetsai@digital-static.net>
This commit is contained in:
@ -15,7 +15,6 @@ import (
|
||||
"time"
|
||||
|
||||
"tailscale.com/tstest"
|
||||
"tailscale.com/types/logid"
|
||||
)
|
||||
|
||||
func TestFastShutdown(t *testing.T) {
|
||||
@ -296,28 +295,6 @@ func TestParseAndRemoveLogLevel(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestPublicIDUnmarshalText(t *testing.T) {
|
||||
const hexStr = "6c60a9e0e7af57170bb1347b2d477e4cbc27d4571a4923b21651456f931e3d55"
|
||||
x := []byte(hexStr)
|
||||
|
||||
var id logid.PublicID
|
||||
if err := id.UnmarshalText(x); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if id.String() != hexStr {
|
||||
t.Errorf("String = %q; want %q", id.String(), hexStr)
|
||||
}
|
||||
err := tstest.MinAllocsPerRun(t, 0, func() {
|
||||
var id logid.PublicID
|
||||
if err := id.UnmarshalText(x); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func unmarshalOne(t *testing.T, body []byte) map[string]any {
|
||||
t.Helper()
|
||||
var entries []map[string]any
|
||||
|
Reference in New Issue
Block a user