net/flowtrack: fix, test String method

I meant to do this in the earlier change and had a git fail.

To atone, add a test too while I'm here.

Updates #12486
Updates #12507

Change-Id: I4943b454a2530cb5047636f37136aa2898d2ffc7
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick
2024-06-18 21:36:25 -07:00
committed by Brad Fitzpatrick
parent 9e0a5cc551
commit 162d593514
2 changed files with 9 additions and 2 deletions

View File

@ -100,10 +100,15 @@ func BenchmarkMapKeys(b *testing.B) {
})
}
func TestJSON(t *testing.T) {
func TestStringJSON(t *testing.T) {
v := MakeTuple(123,
netip.MustParseAddrPort("1.2.3.4:5"),
netip.MustParseAddrPort("6.7.8.9:10"))
if got, want := v.String(), "(IPProto-123 1.2.3.4:5 => 6.7.8.9:10)"; got != want {
t.Errorf("String = %q; want %q", got, want)
}
got, err := json.Marshal(v)
if err != nil {
t.Fatal(err)